@creatok/cli 0.18.0 → 0.18.2-preview.1
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/install.js +13 -19
- package/package.json +7 -6
- package/platform.js +65 -0
- package/run.js +4 -14
package/install.js
CHANGED
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// resolvable, and opportunistically sync embedded skills into existing agent
|
|
5
|
-
// skill directories after npm updates the CLI binary.
|
|
3
|
+
// Missing platform binaries are fatal; skill synchronization remains best-effort.
|
|
6
4
|
const { spawnSync } = require('child_process');
|
|
7
|
-
|
|
8
|
-
const pkg = `@creatok/cli-${process.platform}-${process.arch}`;
|
|
9
|
-
const binName = process.platform === 'win32' ? 'creatok.exe' : 'creatok';
|
|
5
|
+
const { binaryPath, recoverBinary, repairCommand, supported, platform } = require('./platform');
|
|
10
6
|
|
|
11
7
|
function warn(message) {
|
|
12
8
|
console.error(`[creatok] ${message}`);
|
|
13
9
|
}
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
let bin = binaryPath();
|
|
12
|
+
if (!bin) {
|
|
13
|
+
if (!supported) {
|
|
14
|
+
warn(`unsupported platform ${platform}`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
warn('platform package is missing or mismatched; recovering the exact version from the official npm registry');
|
|
16
18
|
try {
|
|
17
|
-
|
|
18
|
-
} catch {
|
|
19
|
-
|
|
19
|
+
bin = recoverBinary();
|
|
20
|
+
} catch (err) {
|
|
21
|
+
warn(`${err.message}\nInstallation failed. Retry: ${repairCommand()}`);
|
|
22
|
+
process.exit(1);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
const bin = binaryPath();
|
|
24
|
-
if (!bin) {
|
|
25
|
-
warn(
|
|
26
|
-
`no prebuilt binary for ${process.platform}-${process.arch}. ` +
|
|
27
|
-
`If this platform should be supported, reinstall with: npm install -g @creatok/cli --force`
|
|
28
|
-
);
|
|
29
|
-
process.exit(0);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
26
|
if (/^(1|true|yes)$/i.test(process.env.CREATOK_SKIP_SKILLS_INSTALL || '')) {
|
|
33
27
|
process.exit(0);
|
|
34
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creatok/cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2-preview.1",
|
|
4
4
|
"description": "CreatOK CLI — drives CreatOK Open Skills (analyze, generate image/video) for TikTok creators and sellers.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"creatok": "run.js"
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"run.js",
|
|
13
|
-
"install.js"
|
|
13
|
+
"install.js",
|
|
14
|
+
"platform.js"
|
|
14
15
|
],
|
|
15
16
|
"license": "UNLICENSED",
|
|
16
17
|
"homepage": "https://github.com/EchoSell/creatok-skills",
|
|
@@ -18,9 +19,9 @@
|
|
|
18
19
|
"node": ">=16"
|
|
19
20
|
},
|
|
20
21
|
"optionalDependencies": {
|
|
21
|
-
"@creatok/cli-darwin-arm64": "0.18.
|
|
22
|
-
"@creatok/cli-win32-x64": "0.18.
|
|
23
|
-
"@creatok/cli-linux-x64": "0.18.
|
|
24
|
-
"@creatok/cli-linux-arm64": "0.18.
|
|
22
|
+
"@creatok/cli-darwin-arm64": "0.18.2-preview.1",
|
|
23
|
+
"@creatok/cli-win32-x64": "0.18.2-preview.1",
|
|
24
|
+
"@creatok/cli-linux-x64": "0.18.2-preview.1",
|
|
25
|
+
"@creatok/cli-linux-arm64": "0.18.2-preview.1"
|
|
25
26
|
}
|
|
26
27
|
}
|
package/platform.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
|
+
const version = require('./package.json').version;
|
|
8
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
9
|
+
const supported = ['darwin-arm64', 'win32-x64', 'linux-x64', 'linux-arm64'].includes(platform);
|
|
10
|
+
const pkg = `@creatok/cli-${platform}`;
|
|
11
|
+
const binName = process.platform === 'win32' ? 'creatok.exe' : 'creatok';
|
|
12
|
+
const recoveryDir = path.join(__dirname, '.platform');
|
|
13
|
+
|
|
14
|
+
function binaryPath() {
|
|
15
|
+
for (const base of [__dirname, recoveryDir]) {
|
|
16
|
+
try {
|
|
17
|
+
const manifest = require.resolve(`${pkg}/package.json`, { paths: [base] });
|
|
18
|
+
if (JSON.parse(fs.readFileSync(manifest, 'utf8')).version !== version) continue;
|
|
19
|
+
const bin = path.join(path.dirname(manifest), 'bin', binName);
|
|
20
|
+
fs.accessSync(bin, process.platform === 'win32' ? fs.constants.F_OK : fs.constants.X_OK);
|
|
21
|
+
return bin;
|
|
22
|
+
} catch { /* Missing or mismatched optional dependency. */ }
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function repairCommand() {
|
|
28
|
+
return `npm install -g @creatok/cli@${version} --include=optional --prefer-online --registry=https://registry.npmjs.org`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// A separate prefix avoids modifying the dependency tree of the outer npm install.
|
|
32
|
+
// npm verifies the registry tarball integrity; lifecycle scripts are disabled.
|
|
33
|
+
function recoverBinary() {
|
|
34
|
+
if (!supported) throw new Error(`unsupported platform ${platform}`);
|
|
35
|
+
const npmCLI = process.env.npm_execpath;
|
|
36
|
+
if (!npmCLI || !fs.existsSync(npmCLI)) throw new Error('npm installer path is unavailable');
|
|
37
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'creatok-platform-'));
|
|
38
|
+
try {
|
|
39
|
+
const result = spawnSync(process.execPath, [npmCLI, 'install', `${pkg}@${version}`,
|
|
40
|
+
'--prefix', recoveryDir, '--global=false', '--ignore-scripts', '--package-lock=false',
|
|
41
|
+
'--no-audit', '--no-fund', '--include=optional', '--prefer-online',
|
|
42
|
+
'--registry=https://registry.npmjs.org', '--cache', path.join(temp, 'cache')], {
|
|
43
|
+
encoding: 'utf8', windowsHide: true, timeout: 120000,
|
|
44
|
+
env: { ...process.env, CREATOK_AUTO_UPDATE: 'off' },
|
|
45
|
+
});
|
|
46
|
+
if (result.error || result.status !== 0) {
|
|
47
|
+
throw new Error(`platform download failed: ${result.error ? result.error.message : (result.stderr || '').trim()}`);
|
|
48
|
+
}
|
|
49
|
+
const bin = binaryPath();
|
|
50
|
+
if (!bin) throw new Error(`download did not provide ${pkg}@${version}`);
|
|
51
|
+
const check = spawnSync(bin, ['version'], {
|
|
52
|
+
encoding: 'utf8', windowsHide: true, timeout: 15000,
|
|
53
|
+
env: { ...process.env, CREATOK_AUTO_UPDATE: 'off', CREATOK_HOME: temp, CREATOK_LOG_DIR: temp },
|
|
54
|
+
});
|
|
55
|
+
if (check.error || check.status !== 0) throw new Error('downloaded binary failed to run');
|
|
56
|
+
let data;
|
|
57
|
+
try { data = JSON.parse(check.stdout).data; } catch { /* Invalid binary output. */ }
|
|
58
|
+
if (!data || data.version !== `v${version}`) throw new Error('downloaded binary version does not match the CLI');
|
|
59
|
+
return bin;
|
|
60
|
+
} finally {
|
|
61
|
+
fs.rmSync(temp, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = { binaryPath, recoverBinary, repairCommand, supported, platform };
|
package/run.js
CHANGED
|
@@ -5,23 +5,13 @@
|
|
|
5
5
|
// optional dependency) and exec it, passing through args, stdio, and exit code.
|
|
6
6
|
const { spawnSync } = require('child_process');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const pkg = `@creatok/cli-${process.platform}-${process.arch}`;
|
|
10
|
-
const binName = process.platform === 'win32' ? 'creatok.exe' : 'creatok';
|
|
11
|
-
try {
|
|
12
|
-
return require.resolve(`${pkg}/bin/${binName}`);
|
|
13
|
-
} catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
8
|
+
const { binaryPath, repairCommand, supported, platform } = require('./platform');
|
|
17
9
|
|
|
18
10
|
const bin = binaryPath();
|
|
19
11
|
if (!bin) {
|
|
20
|
-
console.error(
|
|
21
|
-
`creatok:
|
|
22
|
-
|
|
23
|
-
`Try: npm install -g @creatok/cli --force`
|
|
24
|
-
);
|
|
12
|
+
console.error(supported
|
|
13
|
+
? `creatok: missing platform binary for ${platform}.\nTry: ${repairCommand()}`
|
|
14
|
+
: `creatok: unsupported platform ${platform}.`);
|
|
25
15
|
process.exit(1);
|
|
26
16
|
}
|
|
27
17
|
|