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


TypeScript npmregistry.NpmRegistry类代码示例

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


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

示例1: it

    it('does Basic auth for onprem when service endpoint auth is Token and the TFS server and EP have the same IP', (done: MochaDone) => {
        // Scenario: Onprem and user supplied an IP for the endpoint and the TeamFoundationCollectionUri is a _matching_ IP
        let mockTask = {
            getVariable: (v) => {
                if (v === 'System.TeamFoundationCollectionUri') {
                    return 'http://mytfsserver.example.com';
                }
            },
            getEndpointAuthorization: (id, optional) => {
                return { scheme: 'UsernamePassword', parameters: { 'username': 'USERNAME', 'password': 'PASSWORD' } };
            },
            getEndpointUrl: (id, optional) => {
                return 'http://somepublicrepo.contoso.com:8080/some/random/path';
            }
        };
        mockery.registerMock('vsts-task-lib/task', mockTask);
        const npmregistry = require("npm-common/npmregistry");
        let registry = npmregistry.NpmRegistry.FromServiceEndpoint('endpointId');

        const BASIC_AUTH_PASSWD_REGEX = /\/\/.*\/:_password=PASSWORD.*/g;
        assert(registry.auth.match(BASIC_AUTH_PAT_PASSWD_REGEX), `Auth must contain a password. Auth is: (${registry.auth})`);
        const BASIC_AUTH_PAT_EML_REGEX = /\/\/.*\/:email=USERNAME.*/g;
        assert(registry.auth.match(BASIC_AUTH_PAT_EML_REGEX), `Auth must contain a email. Auth is: (${registry.auth})`);
        const BASIC_AUTH_PAT_USERNAME_REGEX = /\/\/.*\/:username=USERNAME.*/g;
        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,代码行数:29,代码来源: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: 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

示例4: 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

示例5: 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

示例6: getCustomRegistries

export async function getCustomRegistries(packagingLocation: PackagingLocation): Promise<NpmRegistry[]> {
    const workingDir = tl.getInput(NpmTaskInput.WorkingDir) || process.cwd();
    const npmRegistries: INpmRegistry[] = await util.getLocalNpmRegistries(workingDir, packagingLocation.PackagingUris);
    const registryLocation = tl.getInput(NpmTaskInput.CustomRegistry);
    switch (registryLocation) {
        case RegistryLocation.Feed:
            tl.debug(tl.loc('UseFeed'));
            const feedId = tl.getInput(NpmTaskInput.CustomFeed, true);
            npmRegistries.push(await NpmRegistry.FromFeedId(packagingLocation.DefaultPackagingUri, feedId));
            break;
        case RegistryLocation.Npmrc:
            tl.debug(tl.loc('UseNpmrc'));
            const endpointIds = tl.getDelimitedInput(NpmTaskInput.CustomEndpoint, ',');
            if (endpointIds && endpointIds.length > 0) {
                await Promise.all(endpointIds.map(async e => {
                    npmRegistries.push(await NpmRegistry.FromServiceEndpoint(e, true));
                }));
            }
            break;
    }
    return npmRegistries;
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:22,代码来源:npmcustom.ts

示例7:

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


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