v8scli 0.2.0 → 0.2.2
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 +26 -30
- package/bin/v8s.js +2 -2
- package/package.json +1 -1
- package/src/commands/add.js +4 -4
- package/src/commands/init.js +4 -4
- package/src/commands/login.js +1 -1
- package/src/commands/pull.js +3 -3
- package/src/commands/search.js +2 -2
- package/src/common.js +3 -3
- package/templates/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
# v8scli
|
|
2
2
|
|
|
3
|
-
CLI
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
npx
|
|
14
|
-
npx
|
|
15
|
-
npx
|
|
16
|
-
npx
|
|
17
|
-
|
|
3
|
+
CLI for building and publishing V8 `point_script` mods (companion of `v8_scripting`).
|
|
4
|
+
|
|
5
|
+
Every command is `npx v8scli <command>` — the package name matches the bin
|
|
6
|
+
name, so it works both outside a project (npx fetches the package) and inside
|
|
7
|
+
one (the scaffolded project has it as a devDependency).
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npx v8scli init my_mod # scaffold a new mod in ./my_mod
|
|
11
|
+
cd my_mod && npm install
|
|
12
|
+
|
|
13
|
+
npx v8scli build # bundle + dist/my_mod.vjs_c для теста на своём сервере
|
|
14
|
+
npx v8scli login # portal url + api token (dpt_...)
|
|
15
|
+
npx v8scli upload # pack sources, create a version on the portal
|
|
16
|
+
npx v8scli status # versions + review status
|
|
17
|
+
|
|
18
|
+
npx v8scli pull my_mod # fetch the latest uploaded sources from the portal
|
|
19
|
+
npx v8scli search # browse published libraries
|
|
20
|
+
npx v8scli add my_lib # pin a library release (+ typings)
|
|
21
|
+
npx v8scli remove my_lib # drop a dependency (+ its typings)
|
|
22
|
+
npx v8scli update # bump pinned releases to the latest
|
|
23
|
+
npx v8scli deps # (re)download typings of dependencies
|
|
18
24
|
```
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
only your files and the `v8_scripting` SDK can be imported;
|
|
22
|
-
`cs_script/point_script` is provided by the runtime.
|
|
26
|
+
## Local SDK/CLI development
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
so `npm install` never touches the registry:
|
|
28
|
+
`--local` wires the SDK and CLI as `file:` dependencies from your checkouts
|
|
29
|
+
(place them next to each other or set `V8S_LOCAL_SDK`):
|
|
27
30
|
|
|
28
|
-
```
|
|
31
|
+
```
|
|
29
32
|
cd dev_portal/cli && npm install
|
|
30
33
|
cd ~/mods && node /path/to/dev_portal/cli/bin/v8s.js init my_mod --local
|
|
31
|
-
cd my_mod && npm install && npx
|
|
34
|
+
cd my_mod && npm install && npx v8scli build
|
|
32
35
|
```
|
|
33
|
-
|
|
34
|
-
The SDK is looked up next to the CLI checkout (`dev_portal/sdk`);
|
|
35
|
-
override with `V8S_LOCAL_SDK=/path/to/sdk`.
|
|
36
|
-
|
|
37
|
-
Dev portals behind basic auth: pass credentials inside the url on login,
|
|
38
|
-
e.g. `https://user:pass@developer.example.com` — the API token then goes
|
|
39
|
-
in the `X-Api-Token` header automatically.
|
package/bin/v8s.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
2
|
+
// v8scli — CLI разработчика модов. Команды: init, build, login, upload, status, deps.
|
|
3
3
|
import { init } from '../src/commands/init.js';
|
|
4
4
|
import { build } from '../src/commands/build.js';
|
|
5
5
|
import { login } from '../src/commands/login.js';
|
|
@@ -14,7 +14,7 @@ const [, , command, ...args] = process.argv;
|
|
|
14
14
|
|
|
15
15
|
const commands = { init, build, login, upload, status, deps, pull, search, add, remove, update };
|
|
16
16
|
|
|
17
|
-
const usage = `
|
|
17
|
+
const usage = `v8scli <command>
|
|
18
18
|
|
|
19
19
|
init <slug> [--local] scaffold a new mod in ./<slug> (--local: SDK/CLI from checkouts)
|
|
20
20
|
build bundle the mod locally (self-check, dist/<slug>.js)
|
package/package.json
CHANGED
package/src/commands/add.js
CHANGED
|
@@ -5,10 +5,10 @@ import { api, readConfig, readManifest } from '../common.js';
|
|
|
5
5
|
import { deps } from './deps.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* v8scli add <slug>[@version] — подключить библиотеку точным пином релиза.
|
|
9
9
|
* Без версии берётся последний published; typings скачиваются сразу.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* v8scli update [slug] — поднять пин(ы) до последнего published-релиза.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
async function resolveLibrary(config, slug) {
|
|
@@ -38,7 +38,7 @@ async function writeDependency(slug, version) {
|
|
|
38
38
|
|
|
39
39
|
export async function add(args) {
|
|
40
40
|
const spec = args[0];
|
|
41
|
-
if (!spec) throw new Error('usage:
|
|
41
|
+
if (!spec) throw new Error('usage: v8scli add <slug>[@version]');
|
|
42
42
|
|
|
43
43
|
const [slug, requested] = spec.split('@');
|
|
44
44
|
if (!/^[a-z][a-z0-9_]{2,31}$/.test(slug)) throw new Error(`invalid slug "${slug}"`);
|
|
@@ -64,7 +64,7 @@ export async function add(args) {
|
|
|
64
64
|
|
|
65
65
|
export async function remove(args) {
|
|
66
66
|
const slug = args[0];
|
|
67
|
-
if (!slug) throw new Error('usage:
|
|
67
|
+
if (!slug) throw new Error('usage: v8scli remove <slug>');
|
|
68
68
|
|
|
69
69
|
const raw = JSON.parse(await readFile('mod.json', 'utf-8'));
|
|
70
70
|
const dependencies = raw.dependencies || [];
|
package/src/commands/init.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function init(args) {
|
|
|
23
23
|
const isLocal = args.includes('--local');
|
|
24
24
|
const slug = args.find((arg) => !arg.startsWith('-'));
|
|
25
25
|
if (!slug || !/^[a-z][a-z0-9_]{2,31}$/.test(slug))
|
|
26
|
-
throw new Error('usage:
|
|
26
|
+
throw new Error('usage: v8scli init <slug> [--local] (slug: [a-z][a-z0-9_]{2,31})');
|
|
27
27
|
|
|
28
28
|
const local = isLocal ? await resolveLocalPackages() : null;
|
|
29
29
|
|
|
@@ -55,7 +55,7 @@ export async function init(args) {
|
|
|
55
55
|
next steps:
|
|
56
56
|
cd ${slug}
|
|
57
57
|
npm install
|
|
58
|
-
npx
|
|
59
|
-
npx
|
|
60
|
-
npx
|
|
58
|
+
npx v8scli build # self-check bundle
|
|
59
|
+
npx v8scli login # portal url + api token
|
|
60
|
+
npx v8scli upload # create a version on the portal`);
|
|
61
61
|
}
|
package/src/commands/login.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises';
|
|
2
2
|
import { api, readConfig, writeConfig, CONFIG_PATH } from '../common.js';
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// v8scli login [portalUrl] [token] — с аргументами работает без интерактива (CI-friendly).
|
|
5
5
|
export async function login(args = []) {
|
|
6
6
|
const config = await readConfig();
|
|
7
7
|
let [portalUrl, token] = args;
|
package/src/commands/pull.js
CHANGED
|
@@ -8,7 +8,7 @@ import { api, apiBinary, readConfig } from '../common.js';
|
|
|
8
8
|
const TEMPLATES = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'templates');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* v8scli pull <slug> — скачивает исходники последней версии мода с портала.
|
|
12
12
|
*
|
|
13
13
|
* В папке существующего мода (mod.json с тем же slug) обновляет исходники
|
|
14
14
|
* на месте; иначе создаёт ./<slug> с полной обвязкой проекта (package.json,
|
|
@@ -17,7 +17,7 @@ const TEMPLATES = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'tem
|
|
|
17
17
|
export async function pull(args) {
|
|
18
18
|
const slug = args[0];
|
|
19
19
|
if (!slug || !/^[a-z][a-z0-9_]{2,31}$/.test(slug))
|
|
20
|
-
throw new Error('usage:
|
|
20
|
+
throw new Error('usage: v8scli pull <slug>');
|
|
21
21
|
|
|
22
22
|
const config = await readConfig();
|
|
23
23
|
|
|
@@ -63,5 +63,5 @@ export async function pull(args) {
|
|
|
63
63
|
console.log(`pulled ${slug}@${latest.version} -> ${created ? `./${slug}` : '.'}`);
|
|
64
64
|
if (created) console.log(`next: cd ${slug} && npm install`);
|
|
65
65
|
if ((JSON.parse(await readFile(join(target, 'mod.json'), 'utf-8')).dependencies || []).length)
|
|
66
|
-
console.log('dependencies present — run `npx
|
|
66
|
+
console.log('dependencies present — run `npx v8scli deps` to fetch typings');
|
|
67
67
|
}
|
package/src/commands/search.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { api, readConfig } from '../common.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** v8scli search [query] — публичный каталог библиотек портала */
|
|
4
4
|
export async function search(args) {
|
|
5
5
|
const config = await readConfig();
|
|
6
6
|
const query = encodeURIComponent(args.join(' ').trim());
|
|
@@ -15,6 +15,6 @@ export async function search(args) {
|
|
|
15
15
|
for (const lib of libraries) {
|
|
16
16
|
console.log(`${lib.slug}@${lib.latest} ${lib.name} — ${lib.description || 'no description'}`);
|
|
17
17
|
console.log(` by ${lib.ownerNickname || 'unknown'} | versions: ${lib.versions.join(', ')}`);
|
|
18
|
-
console.log(` add: npx
|
|
18
|
+
console.log(` add: npx v8scli add ${lib.slug}`);
|
|
19
19
|
}
|
|
20
20
|
}
|
package/src/common.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function readManifest(dir = process.cwd()) {
|
|
|
23
23
|
try {
|
|
24
24
|
raw = await readFile(join(dir, 'mod.json'), 'utf-8');
|
|
25
25
|
} catch {
|
|
26
|
-
throw new Error('mod.json not found — run from the mod root (or
|
|
26
|
+
throw new Error('mod.json not found — run from the mod root (or v8scli init first)');
|
|
27
27
|
}
|
|
28
28
|
const manifest = JSON.parse(raw);
|
|
29
29
|
if (!manifest.slug || !manifest.entry) throw new Error('mod.json must contain slug and entry');
|
|
@@ -37,7 +37,7 @@ export async function readManifest(dir = process.cwd()) {
|
|
|
37
37
|
*/
|
|
38
38
|
/** Как api(), но возвращает Buffer — для скачивания архивов исходников */
|
|
39
39
|
export async function apiBinary(config, path) {
|
|
40
|
-
if (!config.portalUrl) throw new Error('not logged in — run `
|
|
40
|
+
if (!config.portalUrl) throw new Error('not logged in — run `v8scli login` first');
|
|
41
41
|
const url = new URL(config.portalUrl);
|
|
42
42
|
const headers = {};
|
|
43
43
|
if (config.token) headers['X-Api-Token'] = config.token;
|
|
@@ -53,7 +53,7 @@ export async function apiBinary(config, path) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export async function api(config, path, options = {}) {
|
|
56
|
-
if (!config.portalUrl) throw new Error('not logged in — run `
|
|
56
|
+
if (!config.portalUrl) throw new Error('not logged in — run `v8scli login` first');
|
|
57
57
|
const url = new URL(config.portalUrl);
|
|
58
58
|
const headers = { ...(options.headers ?? {}) };
|
|
59
59
|
if (config.token) headers['X-Api-Token'] = config.token;
|
package/templates/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
7
|
-
"upload": "
|
|
6
|
+
"build": "v8scli build",
|
|
7
|
+
"upload": "v8scli upload"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"v8_scripting": "^0.
|
|
10
|
+
"v8_scripting": "^0.3.0",
|
|
11
11
|
"v8scli": "^0.2.0",
|
|
12
12
|
"typescript": "^5.9.2"
|
|
13
13
|
}
|