@sw-tsdk/core 2.10.0 → 2.11.2-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,5 @@
1
1
  export * from './fs-utils';
2
2
  export * from './netrc';
3
- export * from './git';
4
3
  export * from './strings';
5
4
  export * from './streams';
6
- export * from './git-credential';
7
- export * from './credential-helper';
8
5
  export * from './assertions';
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./fs-utils"), exports);
5
5
  tslib_1.__exportStar(require("./netrc"), exports);
6
- tslib_1.__exportStar(require("./git"), exports);
7
6
  tslib_1.__exportStar(require("./strings"), exports);
8
7
  tslib_1.__exportStar(require("./streams"), exports);
9
- tslib_1.__exportStar(require("./git-credential"), exports);
10
- tslib_1.__exportStar(require("./credential-helper"), exports);
11
8
  tslib_1.__exportStar(require("./assertions"), exports);
12
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,kDAAuB;AACvB,gDAAqB;AACrB,oDAAyB;AACzB,oDAAyB;AACzB,2DAAgC;AAChC,8DAAmC;AACnC,uDAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,kDAAuB;AACvB,oDAAyB;AACzB,oDAAyB;AACzB,uDAA4B"}
package/package.json CHANGED
@@ -9,8 +9,7 @@
9
9
  "fs-extra": "10.0.1",
10
10
  "git-credential-node": "1.1.0",
11
11
  "netrc-parser": "3.1.6",
12
- "npmlog": "6.0.1",
13
- "simple-git": "3.5.0"
12
+ "npmlog": "6.0.1"
14
13
  },
15
14
  "description": "Core library for sw-tsdk",
16
15
  "directories": {
@@ -40,6 +39,6 @@
40
39
  "test": "jest --passWithNoTests"
41
40
  },
42
41
  "types": "lib/index.d.ts",
43
- "version": "2.10.0",
44
- "gitHead": "78e79bfc1ca7826620b1dcc99c32114a38012256"
42
+ "version": "2.11.2-next.3+b820045",
43
+ "gitHead": "b820045036b742454739ba904c99959ce56ecdc5"
45
44
  }
@@ -1,9 +0,0 @@
1
- interface GitCredentialSetupParams {
2
- hostname: string;
3
- username: string;
4
- password: string;
5
- }
6
- export declare function shouldPromptForSetup(hostname: string): Promise<boolean>;
7
- export declare function gitCredentialSetup({ hostname, username, password }: GitCredentialSetupParams): Promise<void>;
8
- export declare function isOurCredentialHelper(cmd: string): boolean;
9
- export {};
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isOurCredentialHelper = exports.gitCredentialSetup = exports.shouldPromptForSetup = void 0;
4
- const tslib_1 = require("tslib");
5
- const git_credential_1 = require("./git-credential");
6
- const simple_git_1 = tslib_1.__importStar(require("simple-git"));
7
- // noinspection JSUnusedGlobalSymbols
8
- async function shouldPromptForSetup(hostname) {
9
- const helper = await getCredentialHelper(hostname);
10
- return helper === '' || !isOurCredentialHelper(helper);
11
- }
12
- exports.shouldPromptForSetup = shouldPromptForSetup;
13
- // noinspection JSUnusedGlobalSymbols
14
- async function gitCredentialSetup({ hostname, username, password }) {
15
- const git = (0, simple_git_1.default)();
16
- // first use a blank value to indicate to git we want to sever the chain of credential helpers
17
- const helper = await getCredentialHelper(hostname);
18
- if (helper === '') {
19
- const configKey = gitCredentialHelperKey(hostname);
20
- await git.addConfig(configKey, '', true, simple_git_1.GitConfigScope.global);
21
- const executable = process.argv[1] || 'sw-tsdk';
22
- await git.addConfig(configKey, `!${executable} auth:git-credential`, true, simple_git_1.GitConfigScope.global);
23
- }
24
- await (0, git_credential_1.reject)(hostname);
25
- await (0, git_credential_1.approve)({ username, url: hostname, password: password });
26
- }
27
- exports.gitCredentialSetup = gitCredentialSetup;
28
- function isOurCredentialHelper(cmd) {
29
- if (!cmd.startsWith('!')) {
30
- return false;
31
- }
32
- return cmd.includes('sw-tsdk');
33
- }
34
- exports.isOurCredentialHelper = isOurCredentialHelper;
35
- async function getCredentialHelper(hostname) {
36
- const git = (0, simple_git_1.default)();
37
- const configKey = gitCredentialHelperKey(hostname);
38
- let config = await git.getConfig(configKey);
39
- if (config && config.value) {
40
- return config.value;
41
- }
42
- config = await git.getConfig('credential.helper');
43
- return (config === null || config === void 0 ? void 0 : config.value) || '';
44
- }
45
- function gitCredentialHelperKey(hostname) {
46
- return `credential.${hostname}.helper`;
47
- }
48
- //# sourceMappingURL=credential-helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"credential-helper.js","sourceRoot":"","sources":["../../src/utils/credential-helper.ts"],"names":[],"mappings":";;;;AAAA,qDAAgD;AAChD,iEAAoD;AAQpD,qCAAqC;AAC9B,KAAK,UAAU,oBAAoB,CAAC,QAAgB;IACzD,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAClD,OAAO,MAAM,KAAK,EAAE,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;AACxD,CAAC;AAHD,oDAGC;AAED,qCAAqC;AAC9B,KAAK,UAAU,kBAAkB,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAA2B;IAC/F,MAAM,GAAG,GAAG,IAAA,oBAAS,GAAE,CAAA;IACvB,8FAA8F;IAC9F,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAClD,IAAI,MAAM,KAAK,EAAE,EAAE;QACjB,MAAM,SAAS,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAA;QAElD,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,2BAAc,CAAC,MAAM,CAAC,CAAA;QAC/D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAA;QAC/C,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,UAAU,sBAAsB,EAAE,IAAI,EAAE,2BAAc,CAAC,MAAM,CAAC,CAAA;KAClG;IAED,MAAM,IAAA,uBAAM,EAAC,QAAQ,CAAC,CAAA;IACtB,MAAM,IAAA,wBAAO,EAAC,EAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAC,CAAC,CAAA;AAC9D,CAAC;AAdD,gDAcC;AAED,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACxB,OAAO,KAAK,CAAA;KACb;IAED,OAAO,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;AAChC,CAAC;AAND,sDAMC;AAED,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACjD,MAAM,GAAG,GAAG,IAAA,oBAAS,GAAE,CAAA;IACvB,MAAM,SAAS,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IAClD,IAAI,MAAM,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;IAE3C,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE;QAC1B,OAAO,MAAM,CAAC,KAAK,CAAA;KACpB;IAED,MAAM,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAA;IAEjD,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,KAAI,EAAE,CAAA;AAC5B,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAgB;IAC9C,OAAO,cAAc,QAAQ,SAAS,CAAA;AACxC,CAAC"}
@@ -1,14 +0,0 @@
1
- interface ApproveOptions {
2
- username: string;
3
- password: string;
4
- url: string;
5
- }
6
- interface FillResult {
7
- username: string;
8
- password: string;
9
- }
10
- export declare function fill(url: string): Promise<FillResult | null>;
11
- export declare function reject(url: string): Promise<void>;
12
- export declare function approve(options: ApproveOptions): Promise<void>;
13
- export declare function hostPrefix(hostname: string): string;
14
- export {};
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hostPrefix = exports.approve = exports.reject = exports.fill = void 0;
4
- const tslib_1 = require("tslib");
5
- const execa_1 = tslib_1.__importDefault(require("execa"));
6
- const credentialRE = /username=([^\n]+)\npassword=([^\n]+)\n/;
7
- function parse(result) {
8
- const match = result.match(credentialRE);
9
- if (!match) {
10
- return null;
11
- }
12
- const username = match[1];
13
- const password = match[2];
14
- if (username.startsWith('Username for ')) {
15
- return null;
16
- }
17
- return { username, password };
18
- }
19
- const fillOpts = (url) => ({
20
- stripEof: false,
21
- reject: false,
22
- encoding: 'utf8',
23
- input: url ? `url=${url}\n\n` : '\n',
24
- env: Object.assign({ GIT_TERMINAL_PROMPT: '0' }, process.env),
25
- });
26
- const rejectOpts = (url) => ({
27
- stripEof: false,
28
- encoding: 'utf8',
29
- input: url ? `url=${url}\n\n` : '\n',
30
- });
31
- const approveOpts = ({ username, password, url }) => ({
32
- stripEof: false,
33
- encoding: 'utf8',
34
- input: (url ? `url=${url}\n` : '') +
35
- `username=${username}\npassword=${password}\n\n`,
36
- });
37
- async function fill(url) {
38
- const result = await (0, execa_1.default)('git', ['credential', 'fill'], fillOpts(url));
39
- if (result.exitCode !== 0) {
40
- return null;
41
- }
42
- return parse(result.stdout);
43
- }
44
- exports.fill = fill;
45
- async function reject(url) {
46
- await (0, execa_1.default)('git', ['credential', 'reject'], rejectOpts(url));
47
- }
48
- exports.reject = reject;
49
- async function approve(options) {
50
- await (0, execa_1.default)('git', ['credential', 'approve'], approveOpts(options));
51
- }
52
- exports.approve = approve;
53
- function hostPrefix(hostname) {
54
- if (hostname.toLocaleLowerCase() === 'localhost') {
55
- return 'http://localhost/';
56
- }
57
- return `https://${hostname}/`;
58
- }
59
- exports.hostPrefix = hostPrefix;
60
- //# sourceMappingURL=git-credential.js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EAAE,KAAK;IACf,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9B,YAAY,QAAQ,cAAc,QAAQ,MAAM;CACrD,CAAC,CAAA;AAEK,KAAK,UAAU,IAAI,CAAC,GAAW;IACpC,MAAM,MAAM,GAAG,MAAM,IAAA,eAAK,EAAC,KAAK,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;IACxE,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE;QACzB,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC;AAPD,oBAOC;AAEM,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,MAAM,IAAA,eAAK,EAAC,KAAK,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;AAC/D,CAAC;AAFD,wBAEC;AAEM,KAAK,UAAU,OAAO,CAAC,OAAuB;IACnD,MAAM,IAAA,eAAK,EAAC,KAAK,EAAE,CAAC,YAAY,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;AACrE,CAAC;AAFD,0BAEC;AAED,SAAgB,UAAU,CAAC,QAAgB;IACzC,IAAI,QAAQ,CAAC,iBAAiB,EAAE,KAAK,WAAW,EAAE;QAChD,OAAO,mBAAmB,CAAA;KAC3B;IAED,OAAO,WAAW,QAAQ,GAAG,CAAA;AAC/B,CAAC;AAND,gCAMC"}
@@ -1,8 +0,0 @@
1
- import { SimpleGit } from 'simple-git';
2
- export declare function getRepoUrl(directory: string): Promise<string>;
3
- interface GitRunnerParams {
4
- gitProtocol: string;
5
- directory: string;
6
- }
7
- export declare function gitRunner({ directory, gitProtocol, }: GitRunnerParams): Promise<SimpleGit>;
8
- export {};
package/lib/utils/git.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gitRunner = exports.getRepoUrl = void 0;
4
- const tslib_1 = require("tslib");
5
- const simple_git_1 = tslib_1.__importDefault(require("simple-git"));
6
- const npmlog_1 = require("npmlog");
7
- const GIT_SSH_COMMAND = 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no';
8
- // noinspection JSUnusedGlobalSymbols
9
- async function getRepoUrl(directory) {
10
- return (0, simple_git_1.default)()
11
- .cwd(directory)
12
- .listRemote(['--get-url']);
13
- }
14
- exports.getRepoUrl = getRepoUrl;
15
- async function gitRunner({ directory = process.cwd(), gitProtocol = 'https', }) {
16
- const git = (0, simple_git_1.default)({
17
- baseDir: directory,
18
- })
19
- .outputHandler((command, stdout, stderr, args) => {
20
- (0, npmlog_1.log)('silly', 'git', `${command} ${args.join(' ')}`);
21
- stdout.on('data', chunk => {
22
- (0, npmlog_1.log)('info', 'git', chunk === null || chunk === void 0 ? void 0 : chunk.toString());
23
- });
24
- });
25
- if (gitProtocol === 'ssh') {
26
- return git.env(Object.assign(Object.assign({}, process.env), { GIT_SSH_COMMAND }));
27
- }
28
- return git;
29
- }
30
- exports.gitRunner = gitRunner;
31
- //# sourceMappingURL=git.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;;;AAAA,oEAA+C;AAC/C,mCAA0B;AAE1B,MAAM,eAAe,GAAG,iEAAiE,CAAA;AAEzF,qCAAqC;AAC9B,KAAK,UAAU,UAAU,CAAC,SAAiB;IAChD,OAAO,IAAA,oBAAS,GAAE;SACjB,GAAG,CAAC,SAAS,CAAC;SACd,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AAC5B,CAAC;AAJD,gCAIC;AAOM,KAAK,UAAU,SAAS,CAAC,EAC9B,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,EACzB,WAAW,GAAG,OAAO,GACL;IAChB,MAAM,GAAG,GAAG,IAAA,oBAAS,EAAC;QACpB,OAAO,EAAE,SAAS;KACnB,CAAC;SACD,aAAa,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAC/C,IAAA,YAAG,EAAC,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACnD,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;YACxB,IAAA,YAAG,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,WAAW,KAAK,KAAK,EAAE;QACzB,OAAO,GAAG,CAAC,GAAG,iCAAK,OAAO,CAAC,GAAG,KAAE,eAAe,IAAE,CAAA;KAClD;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAnBD,8BAmBC"}