当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript NpmRegistry.FromServiceEndpoint方法代码示例

本文整理汇总了TypeScript中npm-common/npmregistry.NpmRegistry.FromServiceEndpoint方法的典型用法代码示例。如果您正苦于以下问题:TypeScript NpmRegistry.FromServiceEndpoint方法的具体用法?TypeScript NpmRegistry.FromServiceEndpoint怎么用?TypeScript NpmRegistry.FromServiceEndpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在npm-common/npmregistry.NpmRegistry的用法示例。


在下文中一共展示了NpmRegistry.FromServiceEndpoint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

    it('does Bearer auth for onprem when service endpoint auth is Token and the endpoint is an IP addr', (done: MochaDone) => {
        // Scenario: Onprem and user supplied an IP for the endpoint.  We must assume that it  is a 3rd party repo
        // and, as such, will use bearer auth.
        let mockTask = {
            getVariable: (v) => {
                if (v === 'System.TeamFoundationCollectionUri') {
                    return 'http://mytfsserver.example.com';
                }
            },
            getEndpointAuthorization: (id, optional) => {
                return { scheme: 'Token', parameters: { 'apitoken': 'AUTHTOKEN' } };
            },
            getEndpointUrl: (id, optional) => {
                return 'http://10.10.10.10:8080/some/random/path';
            }
        };
        mockery.registerMock('vsts-task-lib/task', mockTask);
        const npmregistry = require("npm-common/npmregistry");
        let registry = npmregistry.NpmRegistry.FromServiceEndpoint('endpointId');

        assert(registry.auth.match(BEARER_AUTH_REGEX), `Auth must contain _authToken. Auth is: (${registry.auth})`);
        assert(registry.auth.match(AWLAYS_AUTH_REGEX), `Auth must contain always-auth. Auth is: (${registry.auth})`);

        done();
    });
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:25,代码来源:L0.ts

示例2: require

        (done: MochaDone) => {
        // Scenario: Cross account on visualstudio.com
        let mockTask = {
            getVariable: (v) => {
                if (v === 'System.TeamFoundationCollectionUri') {
                    return 'http://example.visualstudio.com';
                }
            },
            getEndpointAuthorization: (id, optional) => {
                return { scheme: 'Token', parameters: { 'apitoken': 'AUTHTOKEN' } };
            },
            getEndpointUrl: (id, optional) => {
                return 'http://serviceendpoint.visualstudio.com';
            }
        };
        mockery.registerMock('vsts-task-lib/task', mockTask);
        const npmregistry = require("npm-common/npmregistry");
        let registry = npmregistry.NpmRegistry.FromServiceEndpoint('endpointId');

        assert(registry.auth.match(BASIC_AUTH_PAT_PASSWD_REGEX), `Auth must contain a password. Auth is: (${registry.auth})`);
        assert(registry.auth.match(BASIC_AUTH_PAT_EML_REGEX), `Auth must contain a email. Auth is: (${registry.auth})`);
        assert(registry.auth.match(BASIC_AUTH_PAT_USERNAME_REGEX), `Auth must contain a email. Auth is: (${registry.auth})`);
        assert(registry.auth.match(AWLAYS_AUTH_REGEX), `Auth must contain always-auth. Auth is: (${registry.auth})`);

        done();
    });
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:26,代码来源:L0.ts

示例3: async

        async (done: MochaDone) => {
        // Scenario: Cross account on visualstudio.com
        let mockTask = {
            getVariable: (v) => {
                if (v === 'System.TeamFoundationCollectionUri') {
                    return 'http://example.visualstudio.com';
                }
            },
            getEndpointAuthorization: (id, optional) => {
                return { scheme: 'Token', parameters: { 'apitoken': 'AUTHTOKEN' } };
            },
            getEndpointUrl: (id, optional) => {
                return 'http://serviceendpoint.visualstudio.com';
            },
            loc: (key: string) => {
                // no-op
            },
            getHttpProxyConfiguration: (endpoint) => {
                return null;
            }
        };
        mockery.registerMock('vsts-task-lib/task', mockTask);

        mockery.registerMock('typed-rest-client/HttpClient', {
            HttpClient: function() {
                return {
                    get: function(url, headers) {
                        return {
                        then: function(handler) {
                            handler({
                                message: {
                                    statusCode: 401,
                                    rawHeaders: ['x-tfs-foo: abc', 'x-content-type-options: nosniff', 'X-Powered-By: ASP.NET']
                                }
                            });
                        }
                        };
                    }
                };
            }
        });

        const npmregistry = require("npm-common/npmregistry");
        let registry = await npmregistry.NpmRegistry.FromServiceEndpoint('endpointId');

        assert(registry.auth.match(BASIC_AUTH_PAT_PASSWD_REGEX), `Auth must contain a password. Auth is: (${registry.auth})`);
        assert(registry.auth.match(BASIC_AUTH_PAT_EML_REGEX), `Auth must contain a email. Auth is: (${registry.auth})`);
        assert(registry.auth.match(BASIC_AUTH_PAT_USERNAME_REGEX), `Auth must contain a email. Auth is: (${registry.auth})`);
        assert(registry.auth.match(AWLAYS_AUTH_REGEX), `Auth must contain always-auth. Auth is: (${registry.auth})`);

        done();
    });
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:52,代码来源:L0.ts

示例4: it

    it('does Bearer auth for hosted when service endpoint auth is Token and endpoint is 3rd party', async (done: MochaDone) => {
        // Scenario: User is connecting to a non-visualstudio.com registry
        let mockTask = {
            getVariable: (v) => {
                if (v === 'System.TeamFoundationCollectionUri') {
                    return 'http://example.visualstudio.com';
                }
            },
            getEndpointAuthorization: (id, optional) => {
                return { scheme: 'Token', parameters: { 'apitoken': 'AUTHTOKEN' } };
            },
            getEndpointUrl: (id, optional) => {
                return 'http://somepublicrepo.contoso.com:8080/some/random/path';
            },
            getHttpProxyConfiguration: (endpoint) => {
                return null;
            }
        };
        mockery.registerMock('vsts-task-lib/task', mockTask);

        mockery.registerMock('typed-rest-client/HttpClient', {
            HttpClient: function() {
                return {
                    get: function(url, headers) {
                        return {
                        then: function(handler) {
                            handler({
                                message: {
                                    statusCode: 401,
                                    rawHeaders: ['x-content-type-options: nosniff', 'X-Powered-By: ASP.NET']
                                }
                            });
                        }
                        };
                    }
                };
            }
        });

        const npmregistry = require("npm-common/npmregistry");
        let registry = await npmregistry.NpmRegistry.FromServiceEndpoint('endpointId');

        assert(registry.auth.match(BEARER_AUTH_REGEX), `Auth must contain _authToken. Auth is: (${registry.auth})`);
        assert(registry.auth.match(AWLAYS_AUTH_REGEX), `Auth must contain always-auth. Auth is: (${registry.auth})`);

        done();
    });
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:47,代码来源:L0.ts

示例5: getPublishRegistry

export async function getPublishRegistry(packagingLocation: PackagingLocation): Promise<INpmRegistry> {
    let npmRegistry: INpmRegistry;
    const registryLocation = tl.getInput(NpmTaskInput.PublishRegistry);
    switch (registryLocation) {
        case RegistryLocation.Feed:
            tl.debug(tl.loc('PublishFeed'));
            const feedId = tl.getInput(NpmTaskInput.PublishFeed, true);
            npmRegistry = await NpmRegistry.FromFeedId(packagingLocation.DefaultPackagingUri, feedId);
            break;
        case RegistryLocation.External:
            tl.debug(tl.loc('PublishExternal'));
            const endpointId = tl.getInput(NpmTaskInput.PublishEndpoint, true);
            npmRegistry = await NpmRegistry.FromServiceEndpoint(endpointId);
            break;
    }
    return npmRegistry;
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:17,代码来源:npmpublish.ts

示例6:

 await Promise.all(endpointIds.map(async e => {
     endpointRegistries.push(await npmregistry.NpmRegistry.FromServiceEndpoint(e, true));
 }));
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:3,代码来源:npmauth.ts

示例7:

 endpointRegistries = endpointIds.map(e => npmregistry.NpmRegistry.FromServiceEndpoint(e, true));
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:1,代码来源:npmauth.ts


注:本文中的npm-common/npmregistry.NpmRegistry.FromServiceEndpoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。