itiger 0.1.0 → 0.1.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.
- package/README.md +8 -5
- package/package.json +1 -1
- package/src/cli.js +3 -3
- package/src/npm-adapter.js +1 -0
- package/src/process.js +18 -5
- package/src/skills-adapter.js +7 -7
package/README.md
CHANGED
|
@@ -10,16 +10,19 @@ npx itiger install -g @tiger/example
|
|
|
10
10
|
|
|
11
11
|
`skills add owner/repo` is translated to
|
|
12
12
|
`https://git.tigerbrokers.net/owner/repo.git`; Git authentication remains under
|
|
13
|
-
the user's normal SSH keys or Git credential helper.
|
|
14
|
-
|
|
13
|
+
the user's normal SSH keys or Git credential helper. All other `skills`
|
|
14
|
+
commands, arguments, output, and exit codes are passed through unchanged.
|
|
15
15
|
|
|
16
16
|
When installing an `@tiger/*` package, `itiger` adds
|
|
17
17
|
`--@tiger:registry=http://r.npm.tigerfintech.com` unless `--registry` or an
|
|
18
18
|
explicit `--@tiger:registry` option is already present. Non-Tiger packages are
|
|
19
|
-
delegated without registry changes.
|
|
19
|
+
delegated without registry changes. Other npm commands are delegated with all
|
|
20
|
+
arguments, output, and exit codes unchanged.
|
|
20
21
|
|
|
21
|
-
Requirements: Node.js 18 or newer, plus
|
|
22
|
-
commands
|
|
22
|
+
Requirements: Node.js 18 or newer, plus npm for package installation. For
|
|
23
|
+
`skills` commands, the locally installed `skills` CLI is used when available;
|
|
24
|
+
otherwise `npx --yes skills` downloads and runs the public CLI without
|
|
25
|
+
persisting credentials or changing the user's global installation.
|
|
23
26
|
|
|
24
27
|
## Development
|
|
25
28
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -8,12 +8,12 @@ async function main() {
|
|
|
8
8
|
if (args[0] === 'skills') {
|
|
9
9
|
return runSkills(args.slice(1));
|
|
10
10
|
}
|
|
11
|
-
if (args
|
|
11
|
+
if (args.length > 0) {
|
|
12
12
|
return runNpm(args);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
process.stderr.write('Usage: itiger skills
|
|
16
|
-
process.stderr.write(' itiger
|
|
15
|
+
process.stderr.write('Usage: itiger skills <skills command> [skills options...]\n');
|
|
16
|
+
process.stderr.write(' itiger <npm command> [npm options...]\n');
|
|
17
17
|
return 2;
|
|
18
18
|
}
|
|
19
19
|
|
package/src/npm-adapter.js
CHANGED
|
@@ -16,6 +16,7 @@ function hasTigerPackage(args) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function transformArgs(args) {
|
|
19
|
+
if (args[0] !== 'install' && args[0] !== 'i') return [...args];
|
|
19
20
|
if (!hasTigerPackage(args) || hasExplicitRegistry(args)) return [...args];
|
|
20
21
|
return [...args, `--@tiger:registry=${TIGER_REGISTRY}`];
|
|
21
22
|
}
|
package/src/process.js
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
const { spawn } = require('node:child_process');
|
|
2
2
|
|
|
3
|
-
function runCommand(command, args) {
|
|
3
|
+
function runCommand(command, args, fallback) {
|
|
4
4
|
return new Promise((resolve) => {
|
|
5
5
|
let child;
|
|
6
|
+
let settled = false;
|
|
6
7
|
try {
|
|
7
8
|
child = spawn(command, args, { stdio: 'inherit' });
|
|
8
9
|
} catch (error) {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
if (fallback) {
|
|
11
|
+
runCommand(fallback.command, fallback.args).then(resolve);
|
|
12
|
+
} else {
|
|
13
|
+
process.stderr.write(`itiger: unable to start ${command}: ${error.message}\n`);
|
|
14
|
+
resolve(1);
|
|
15
|
+
}
|
|
11
16
|
return;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
child.on('error', (error) => {
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
if (settled) return;
|
|
21
|
+
settled = true;
|
|
22
|
+
if (fallback && error.code === 'ENOENT') {
|
|
23
|
+
runCommand(fallback.command, fallback.args).then(resolve);
|
|
24
|
+
} else {
|
|
25
|
+
process.stderr.write(`itiger: unable to start ${command}: ${error.message}\n`);
|
|
26
|
+
resolve(1);
|
|
27
|
+
}
|
|
17
28
|
});
|
|
18
29
|
child.on('exit', (code, signal) => {
|
|
30
|
+
if (settled) return;
|
|
31
|
+
settled = true;
|
|
19
32
|
resolve(code === null ? 128 + signalNumber(signal) : code);
|
|
20
33
|
});
|
|
21
34
|
});
|
package/src/skills-adapter.js
CHANGED
|
@@ -8,9 +8,9 @@ function mapRepository(repository) {
|
|
|
8
8
|
return `https://${INTERNAL_GIT_HOST}/${githubUrl[1]}/${githubUrl[2]}.git`;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const shorthand = repository.match(/^([^/]
|
|
11
|
+
const shorthand = repository.match(/^([^/]+\/.+?)(?:\.git)?$/);
|
|
12
12
|
if (shorthand) {
|
|
13
|
-
return `https://${INTERNAL_GIT_HOST}/${shorthand[1]}
|
|
13
|
+
return `https://${INTERNAL_GIT_HOST}/${shorthand[1]}.git`;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
return repository;
|
|
@@ -28,11 +28,11 @@ function transformArgs(args) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function runSkills(args) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const transformedArgs = transformArgs(args);
|
|
32
|
+
return runCommand('skills', transformedArgs, {
|
|
33
|
+
command: 'npx',
|
|
34
|
+
args: ['--yes', 'skills', ...transformedArgs],
|
|
35
|
+
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
module.exports = { INTERNAL_GIT_HOST, mapRepository, transformArgs, runSkills };
|