v8scli 0.2.0 → 0.2.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/README.md CHANGED
@@ -1,39 +1,35 @@
1
1
  # v8scli
2
2
 
3
- CLI (`v8s`) for building and publishing V8 `point_script` mods.
4
- Companion of the `v8_scripting` SDK.
5
-
6
- The first call runs through the package name — `npx v8s` would look for a
7
- package called `v8s`, which does not exist. Inside the scaffolded project the
8
- CLI is a devDependency, so plain `npx v8s` works from there on:
9
-
10
- ```bash
11
- npx v8scli init my_mod # scaffold (inside a project plain `npx v8s` works)
12
- cd my_mod && npm i
13
- npx v8s build # bundle + dist/my_mod.vjs_c для теста на своём сервере
14
- npx v8s login # portal url + api token (dpt_...)
15
- npx v8s upload # pack sources, create a version on the portal
16
- npx v8s status # versions + review status
17
- npx v8s deps # download typings of library dependencies
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
- Rules enforced at build time (same as on the portal):
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
- Before the npm release the packages are installed from checkouts —
25
- `init --local` writes the SDK and the CLI into the project as `file:` deps,
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
- ```bash
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 v8s build
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
- // v8s — CLI разработчика модов. Команды: init, build, login, upload, status, deps.
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 = `v8s <command>
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v8scli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI for building and publishing V8 point_script mods (companion of v8_scripting)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -5,10 +5,10 @@ import { api, readConfig, readManifest } from '../common.js';
5
5
  import { deps } from './deps.js';
6
6
 
7
7
  /**
8
- * v8s add <slug>[@version] — подключить библиотеку точным пином релиза.
8
+ * v8scli add <slug>[@version] — подключить библиотеку точным пином релиза.
9
9
  * Без версии берётся последний published; typings скачиваются сразу.
10
10
  *
11
- * v8s update [slug] — поднять пин(ы) до последнего published-релиза.
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: v8s add <slug>[@version]');
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: v8s remove <slug>');
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 || [];
@@ -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: v8s init <slug> [--local] (slug: [a-z][a-z0-9_]{2,31})');
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 v8s build # self-check bundle
59
- npx v8s login # portal url + api token
60
- npx v8s upload # create a version on the portal`);
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
  }
@@ -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
- // v8s login [portalUrl] [token] — с аргументами работает без интерактива (CI-friendly).
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;
@@ -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
- * v8s pull <slug> — скачивает исходники последней версии мода с портала.
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: v8s pull <slug>');
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 v8s deps` to fetch typings');
66
+ console.log('dependencies present — run `npx v8scli deps` to fetch typings');
67
67
  }
@@ -1,6 +1,6 @@
1
1
  import { api, readConfig } from '../common.js';
2
2
 
3
- /** v8s search [query] — публичный каталог библиотек портала */
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 v8s add ${lib.slug}`);
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 v8s init first)');
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 `v8s login` first');
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 `v8s login` first');
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;
@@ -3,8 +3,8 @@
3
3
  "private": true,
4
4
  "type": "module",
5
5
  "scripts": {
6
- "build": "v8s build",
7
- "upload": "v8s upload"
6
+ "build": "v8scli build",
7
+ "upload": "v8scli upload"
8
8
  },
9
9
  "devDependencies": {
10
10
  "v8_scripting": "^0.2.1",