@ttmg/cli 0.4.6-vibe-beta.3 → 0.4.6-vibe-beta.4
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 +19 -0
- package/dist/index.js +1419 -569
- package/dist/index.js.map +1 -1
- package/dist/package.json +5 -2
- package/dist/scripts/preview-page-server-smoke.js +63 -0
- package/dist/scripts/verify-agent-contract.js +49 -0
- package/package.json +5 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttmg/cli",
|
|
3
|
-
"version": "0.4.6-vibe-beta.
|
|
3
|
+
"version": "0.4.6-vibe-beta.4",
|
|
4
4
|
"description": "TikTok Mini Game Command Line Tool",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"verify:agent-contract": "node scripts/verify-agent-contract.js",
|
|
21
21
|
"test:network": "node -r ts-node/register src/commands/native/dev/utils/getLocalIPs.test.ts",
|
|
22
22
|
"test:upload-preview": "node scripts/run-ts-test.js src/commands/common/upload.test.ts",
|
|
23
|
+
"test:preview-page": "node scripts/run-ts-test.js src/commands/common/previewPageServer.test.ts",
|
|
24
|
+
"test:preview-page-detached": "node scripts/run-ts-test.js src/commands/common/previewPageDetached.test.ts",
|
|
25
|
+
"test:preview-page-process": "node scripts/preview-page-server-smoke.js",
|
|
23
26
|
"test:login": "node scripts/run-ts-test.js src/commands/common/login.test.ts",
|
|
24
27
|
"test:auth": "node scripts/run-ts-test.js src/commands/common/auth.test.ts",
|
|
25
28
|
"test:capabilities": "node scripts/run-ts-test.js src/commands/common/capabilities.test.ts",
|
|
@@ -33,7 +36,7 @@
|
|
|
33
36
|
"test:check-ai": "node scripts/run-ts-test.js src/commands/native/check/ai.test.ts",
|
|
34
37
|
"test:build-structured": "node scripts/run-ts-test.js src/commands/native/build/build.test.ts",
|
|
35
38
|
"test:doctor": "node scripts/run-ts-test.js src/commands/native/doctor/doctor.test.ts",
|
|
36
|
-
"test:agent-contract": "npm run test:login && npm run test:auth && npm run test:capabilities && npm run test:test-account && npm run test:upload-preview && npm run test:check && npm run test:check-ai && npm run test:build-structured && npm run test:doctor && npm run test:dev-session && npm run test:dev-session-command && npm run test:dev-runtime-event && npm run test:network && npx tsc --noEmit && npm run build && npm run verify:dist-version && npm run verify:agent-contract",
|
|
39
|
+
"test:agent-contract": "npm run test:login && npm run test:auth && npm run test:capabilities && npm run test:test-account && npm run test:upload-preview && npm run test:preview-page && npm run test:check && npm run test:check-ai && npm run test:build-structured && npm run test:doctor && npm run test:dev-session && npm run test:dev-session-command && npm run test:dev-runtime-event && npm run test:network && npx tsc --noEmit && npm run build && npm run test:preview-page-process && npm run test:preview-page-detached && npm run verify:dist-version && npm run verify:agent-contract",
|
|
37
40
|
"test:agent-contract:full": "npm run test:agent-contract && npm run test:dev-default-process && npm run test:dev-game-ready-process",
|
|
38
41
|
"publish:beta": "npm publish --registry=https://registry.npmjs.org/ --access public --tag beta",
|
|
39
42
|
"setup": "node scripts/setup.js",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const assert = require('node:assert/strict');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
const { spawn } = require('node:child_process');
|
|
4
|
+
|
|
5
|
+
const entryPath = path.resolve(__dirname, '../dist/index.js');
|
|
6
|
+
const child = spawn(process.execPath, [entryPath, '__preview-page-server'], {
|
|
7
|
+
detached: true,
|
|
8
|
+
windowsHide: true,
|
|
9
|
+
stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const ready = new Promise((resolve, reject) => {
|
|
13
|
+
const timeout = setTimeout(
|
|
14
|
+
() => reject(new Error('preview page worker did not become ready')),
|
|
15
|
+
5000,
|
|
16
|
+
);
|
|
17
|
+
child.once('error', reject);
|
|
18
|
+
child.once('exit', code =>
|
|
19
|
+
reject(new Error(`preview page worker exited early (${code})`)),
|
|
20
|
+
);
|
|
21
|
+
child.on('message', message => {
|
|
22
|
+
if (message?.type === 'error') reject(new Error(message.error));
|
|
23
|
+
if (message?.type === 'ready') {
|
|
24
|
+
clearTimeout(timeout);
|
|
25
|
+
resolve(message);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
async function main() {
|
|
31
|
+
child.send({
|
|
32
|
+
type: 'start',
|
|
33
|
+
authorizationUrl: 'https://www.tiktok.com/ttmg/dev/client-key',
|
|
34
|
+
previewUrl: 'https://www.tiktok.com/preview/process-smoke',
|
|
35
|
+
clientKey: 'client-key',
|
|
36
|
+
projectName: 'Process Smoke Game',
|
|
37
|
+
versionId: 'asset-smoke',
|
|
38
|
+
token: 'b'.repeat(48),
|
|
39
|
+
ttlMs: 5000,
|
|
40
|
+
});
|
|
41
|
+
const result = await ready;
|
|
42
|
+
assert.match(result.url, /^http:\/\/127\.0\.0\.1:\d+\/preview\/b{48}$/);
|
|
43
|
+
const response = await fetch(result.url);
|
|
44
|
+
assert.equal(response.status, 200);
|
|
45
|
+
assert.equal(
|
|
46
|
+
response.headers.get('content-type'),
|
|
47
|
+
'text/html; charset=utf-8',
|
|
48
|
+
);
|
|
49
|
+
const html = await response.text();
|
|
50
|
+
assert.match(html, /Process Smoke Game/);
|
|
51
|
+
assert.equal((html.match(/data:image\/png;base64,/g) || []).length, 2);
|
|
52
|
+
console.log('preview page server process smoke passed');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.catch(error => {
|
|
57
|
+
console.error(error);
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
})
|
|
60
|
+
.finally(() => {
|
|
61
|
+
if (child.connected) child.disconnect();
|
|
62
|
+
child.kill();
|
|
63
|
+
});
|
|
@@ -104,6 +104,53 @@ assert.equal(
|
|
|
104
104
|
);
|
|
105
105
|
assert.equal(capabilities.commands.dev.outputModesMutuallyExclusive, true);
|
|
106
106
|
assert.equal(capabilities.commands.uploadPreview.platformWrite, true);
|
|
107
|
+
assert.equal(
|
|
108
|
+
capabilities.commands.uploadPreview.previewPage.option,
|
|
109
|
+
'--serve-preview-page',
|
|
110
|
+
);
|
|
111
|
+
assert.equal(capabilities.commands.uploadPreview.previewPage.inMemory, true);
|
|
112
|
+
assert.equal(
|
|
113
|
+
capabilities.commands.uploadPreview.previewPage.reuseScope,
|
|
114
|
+
'clientKey',
|
|
115
|
+
);
|
|
116
|
+
assert.equal(capabilities.commands.uploadPreview.previewPage.latestOnly, true);
|
|
117
|
+
assert.equal(
|
|
118
|
+
capabilities.commands.uploadPreview.previewPage.renewsTtlOnUpload,
|
|
119
|
+
true,
|
|
120
|
+
);
|
|
121
|
+
assert.equal(
|
|
122
|
+
capabilities.commands.uploadPreview.previewPage.textModeAutoOpen,
|
|
123
|
+
true,
|
|
124
|
+
);
|
|
125
|
+
assert.equal(
|
|
126
|
+
capabilities.commands.uploadPreview.previewPage.structuredModeAutoOpen,
|
|
127
|
+
false,
|
|
128
|
+
);
|
|
129
|
+
assert.equal(
|
|
130
|
+
capabilities.commands.uploadPreview.previewPage.noOpenOption,
|
|
131
|
+
'--no-open',
|
|
132
|
+
);
|
|
133
|
+
assert.equal(
|
|
134
|
+
capabilities.commands.uploadPreview.previewPage.presentation.preferredAction,
|
|
135
|
+
'open_url',
|
|
136
|
+
);
|
|
137
|
+
assert.equal(
|
|
138
|
+
capabilities.commands.uploadPreview.previewPage.presentation.terminalInline,
|
|
139
|
+
false,
|
|
140
|
+
);
|
|
141
|
+
assert.equal(
|
|
142
|
+
capabilities.commands.uploadPreview.previewPage.presentation.sameHostRequired,
|
|
143
|
+
true,
|
|
144
|
+
);
|
|
145
|
+
assert.equal(capabilities.commands.uploadPreview.previewPage.ttlSeconds, 3600);
|
|
146
|
+
assert.equal(
|
|
147
|
+
capabilities.commands.uploadPreview.previewPage.expiredNoticeTtlSeconds,
|
|
148
|
+
3600,
|
|
149
|
+
);
|
|
150
|
+
assert.equal(
|
|
151
|
+
capabilities.commands.uploadPreview.previewPage.localhostOnly,
|
|
152
|
+
true,
|
|
153
|
+
);
|
|
107
154
|
assert.equal(capabilities.dev.gameReadyProtocol, true);
|
|
108
155
|
assert.equal(capabilities.dev.gameReady, false);
|
|
109
156
|
assertNoSecretKeys(capabilities, 'capabilities');
|
|
@@ -143,6 +190,8 @@ assert.notEqual(
|
|
|
143
190
|
const uploadHelp = runCli(['upload', '--help']);
|
|
144
191
|
assertExit(uploadHelp, 0, 'upload help');
|
|
145
192
|
assert.match(uploadHelp.stdout, /--preview\b/);
|
|
193
|
+
assert.match(uploadHelp.stdout, /--serve-preview-page\b/);
|
|
194
|
+
assert.match(uploadHelp.stdout, /--no-open\b/);
|
|
146
195
|
assert.doesNotMatch(uploadHelp.stdout, /--allow-upload\b/);
|
|
147
196
|
|
|
148
197
|
const tempDirectory = fs.mkdtempSync(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttmg/cli",
|
|
3
|
-
"version": "0.4.6-vibe-beta.
|
|
3
|
+
"version": "0.4.6-vibe-beta.4",
|
|
4
4
|
"description": "TikTok Mini Game Command Line Tool",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"verify:agent-contract": "node scripts/verify-agent-contract.js",
|
|
21
21
|
"test:network": "node -r ts-node/register src/commands/native/dev/utils/getLocalIPs.test.ts",
|
|
22
22
|
"test:upload-preview": "node scripts/run-ts-test.js src/commands/common/upload.test.ts",
|
|
23
|
+
"test:preview-page": "node scripts/run-ts-test.js src/commands/common/previewPageServer.test.ts",
|
|
24
|
+
"test:preview-page-detached": "node scripts/run-ts-test.js src/commands/common/previewPageDetached.test.ts",
|
|
25
|
+
"test:preview-page-process": "node scripts/preview-page-server-smoke.js",
|
|
23
26
|
"test:login": "node scripts/run-ts-test.js src/commands/common/login.test.ts",
|
|
24
27
|
"test:auth": "node scripts/run-ts-test.js src/commands/common/auth.test.ts",
|
|
25
28
|
"test:capabilities": "node scripts/run-ts-test.js src/commands/common/capabilities.test.ts",
|
|
@@ -33,7 +36,7 @@
|
|
|
33
36
|
"test:check-ai": "node scripts/run-ts-test.js src/commands/native/check/ai.test.ts",
|
|
34
37
|
"test:build-structured": "node scripts/run-ts-test.js src/commands/native/build/build.test.ts",
|
|
35
38
|
"test:doctor": "node scripts/run-ts-test.js src/commands/native/doctor/doctor.test.ts",
|
|
36
|
-
"test:agent-contract": "npm run test:login && npm run test:auth && npm run test:capabilities && npm run test:test-account && npm run test:upload-preview && npm run test:check && npm run test:check-ai && npm run test:build-structured && npm run test:doctor && npm run test:dev-session && npm run test:dev-session-command && npm run test:dev-runtime-event && npm run test:network && npx tsc --noEmit && npm run build && npm run verify:dist-version && npm run verify:agent-contract",
|
|
39
|
+
"test:agent-contract": "npm run test:login && npm run test:auth && npm run test:capabilities && npm run test:test-account && npm run test:upload-preview && npm run test:preview-page && npm run test:check && npm run test:check-ai && npm run test:build-structured && npm run test:doctor && npm run test:dev-session && npm run test:dev-session-command && npm run test:dev-runtime-event && npm run test:network && npx tsc --noEmit && npm run build && npm run test:preview-page-process && npm run test:preview-page-detached && npm run verify:dist-version && npm run verify:agent-contract",
|
|
37
40
|
"test:agent-contract:full": "npm run test:agent-contract && npm run test:dev-default-process && npm run test:dev-game-ready-process",
|
|
38
41
|
"publish:beta": "npm publish --registry=https://registry.npmjs.org/ --access public --tag beta",
|
|
39
42
|
"setup": "node scripts/setup.js",
|