@slidevideo/cli 0.1.1 → 0.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.2
6
+
7
+ - Remind users to retain their custom npm installation prefix when they run an update command.
8
+
9
+ - Recover background update checks after interrupted or failed attempt reservations.
10
+
11
+ - Notify interactive CLI users about newer npm versions with a daily background check, cached notices and an opt-out.
12
+
5
13
  ## 0.1.1
6
14
 
7
15
  ### Changes
package/README.md CHANGED
@@ -20,6 +20,8 @@ A completed build writes `runs/hello-001/final.mp4`. Use `slidevideo setup --lic
20
20
 
21
21
  To draft or edit a storyboard, open your presentation folder in your coding agent and ask it to run `slidevideo skill`. The CLI includes the skill and its storyboard and recording references.
22
22
 
23
+ Interactive calls check npm in the background at most once every 24 hours and show cached update notices on later calls. Stable installations use `latest`; existing alpha installations use `alpha`. Notices include an exact-version upgrade command. If you installed with `--prefix`, add the same `--prefix` option to that command so npm updates the copy on your `PATH`. Set `SLIDEVIDEO_NO_UPDATE_CHECK=1` to disable checks and notices. CI, noninteractive calls, `--json` and `--quiet` skip both.
24
+
23
25
  See the [user manual](https://slidevideo.io/guide.html) for host prerequisites and a first build, and the [changelog](CHANGELOG.md) for release notes. Run `slidevideo --help` for the installed command reference.
24
26
 
25
27
  Run `slidevideo license` for the bundled license terms or `slidevideo impressum` for the provider's contact details. Both commands work offline. You can also read the [license terms](https://slidevideo.io/license.html) and [Impressum](https://slidevideo.io/impressum.html) on the website.
package/dist/cli.js CHANGED
@@ -11,6 +11,7 @@ import { packagePath } from './installation.js';
11
11
  import { withExecutables } from './executables.js';
12
12
  import { setup } from './setup.js';
13
13
  import { setupLicense } from './setup-license.js';
14
+ import { notifyUpdate } from './update-check.js';
14
15
  const commands = ['inspect', 'validate', 'play', 'tts', 'resolve', 'record', 'assemble', 'build'];
15
16
  const documents = new Map([
16
17
  ['license', 'LICENSE-TERMS.md'],
@@ -43,6 +44,7 @@ try {
43
44
  json: { type: 'boolean' }, quiet: { type: 'boolean' }, resume: { type: 'boolean' }, 'verify-timing': { type: 'boolean' }, help: { type: 'boolean', short: 'h' }, version: { type: 'boolean' },
44
45
  }, allowPositionals: true });
45
46
  command = positionals[0] ?? 'help';
47
+ notifyUpdate(Boolean(values.json), Boolean(values.quiet));
46
48
  if (values.version) {
47
49
  const { version } = JSON.parse(await readFile(packagePath('package.json'), 'utf8'));
48
50
  console.log(values.json ? JSON.stringify({ version: 1, package_version: version }) : version);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ import { renameSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { userDataDirectory } from './installation.js';
4
+ import { updateVersion } from './update-check.js';
5
+ const channel = process.argv[2];
6
+ if (channel === 'latest' || channel === 'alpha') {
7
+ const deadline = setTimeout(() => process.exit(0), 5000);
8
+ try {
9
+ const response = await fetch(`https://registry.npmjs.org/@slidevideo%2fcli/${channel}`, {
10
+ signal: AbortSignal.timeout(3000),
11
+ });
12
+ if (response.ok) {
13
+ const result = await response.json();
14
+ const version = updateVersion(result?.version, channel);
15
+ if (version) {
16
+ const directory = join(userDataDirectory(), 'updates');
17
+ const pending = join(directory, `${channel}.${process.pid}.tmp`);
18
+ writeFileSync(pending, JSON.stringify(version), { mode: 0o600 });
19
+ renameSync(pending, join(directory, `${channel}.json`));
20
+ }
21
+ }
22
+ }
23
+ catch { }
24
+ finally {
25
+ clearTimeout(deadline);
26
+ }
27
+ process.exit(0);
28
+ }
@@ -0,0 +1,4 @@
1
+ export type UpdateChannel = 'latest' | 'alpha';
2
+ export declare function updateChannel(version: string): UpdateChannel | undefined;
3
+ export declare function updateVersion(value: unknown, channel: UpdateChannel): string | undefined;
4
+ export declare function notifyUpdate(json: boolean, quiet: boolean): void;
@@ -0,0 +1,79 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { gt, parse, valid } from 'semver';
6
+ import { lockSync } from 'proper-lockfile';
7
+ import { packagePath, userDataDirectory } from './installation.js';
8
+ const intervalMs = 24 * 60 * 60 * 1000;
9
+ export function updateChannel(version) {
10
+ const parsed = parse(version);
11
+ if (!parsed)
12
+ return undefined;
13
+ if (parsed.prerelease.length === 0)
14
+ return 'latest';
15
+ return parsed.prerelease[0] === 'alpha' ? 'alpha' : undefined;
16
+ }
17
+ export function updateVersion(value, channel) {
18
+ if (typeof value !== 'string')
19
+ return undefined;
20
+ const version = valid(value);
21
+ return version && updateChannel(version) === channel ? version : undefined;
22
+ }
23
+ export function notifyUpdate(json, quiet) {
24
+ if (json || quiet || process.env.SLIDEVIDEO_NO_UPDATE_CHECK === '1'
25
+ || (process.env.CI && process.env.CI !== 'false')
26
+ || process.env.GITHUB_ACTIONS || process.env.TF_BUILD || process.env.BUILD_NUMBER
27
+ || !process.stdin.isTTY || !process.stdout.isTTY || !process.stderr.isTTY)
28
+ return;
29
+ try {
30
+ const { version: installed } = JSON.parse(readFileSync(packagePath('package.json'), 'utf8'));
31
+ if (typeof installed !== 'string')
32
+ return;
33
+ const channel = updateChannel(installed);
34
+ if (!channel)
35
+ return;
36
+ const directory = join(userDataDirectory(), 'updates');
37
+ let available;
38
+ try {
39
+ available = updateVersion(JSON.parse(readFileSync(join(directory, `${channel}.json`), 'utf8')), channel);
40
+ }
41
+ catch { }
42
+ if (available && gt(available, installed)) {
43
+ process.stderr.write(`[slidevideo] Update available: ${installed} → ${available}\nRun npm install -g @slidevideo/cli@${available}\nFor a custom install prefix, add the original --prefix option to this command.\n`);
44
+ }
45
+ mkdirSync(directory, { recursive: true });
46
+ const attempt = join(directory, 'attempt.json');
47
+ const release = lockSync(attempt, { realpath: false, stale: 10000, onCompromised: () => { } });
48
+ const pending = join(directory, `attempt.${process.pid}.tmp`);
49
+ try {
50
+ try {
51
+ const lastAttempt = JSON.parse(readFileSync(attempt, 'utf8'));
52
+ if (typeof lastAttempt !== 'number' || !Number.isFinite(lastAttempt))
53
+ return;
54
+ if (Date.now() - lastAttempt < intervalMs)
55
+ return;
56
+ }
57
+ catch (error) {
58
+ if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
59
+ return;
60
+ }
61
+ writeFileSync(pending, JSON.stringify(Date.now()), { mode: 0o600, flush: true });
62
+ renameSync(pending, attempt);
63
+ }
64
+ finally {
65
+ try {
66
+ rmSync(pending, { force: true });
67
+ }
68
+ finally {
69
+ release();
70
+ }
71
+ }
72
+ const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel], {
73
+ detached: true, stdio: 'ignore', windowsHide: true,
74
+ });
75
+ child.on('error', () => { });
76
+ child.unref();
77
+ }
78
+ catch { }
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidevideo/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Turn a slide deck into a narrated video.",
5
5
  "license": "SEE LICENSE IN LICENSE-TERMS.md",
6
6
  "type": "module",
@@ -13,7 +13,9 @@
13
13
  "@slidev/theme-default": "0.25.0",
14
14
  "ajv": "8.20.0",
15
15
  "playwright": "1.65.1",
16
+ "proper-lockfile": "4.1.2",
16
17
  "saxes": "6.0.0",
18
+ "semver": "7.8.6",
17
19
  "vue": "3.5.45",
18
20
  "yaml": "2.9.1"
19
21
  },
@@ -102,6 +104,10 @@
102
104
  "dist/storyboard.js",
103
105
  "dist/timing.d.ts",
104
106
  "dist/timing.js",
107
+ "dist/update-check-worker.d.ts",
108
+ "dist/update-check-worker.js",
109
+ "dist/update-check.d.ts",
110
+ "dist/update-check.js",
105
111
  "schemas/annotation-geometry.v1.json",
106
112
  "schemas/revoked-keys.schema.json",
107
113
  "schemas/run-manifest.v1.json",