slicejs-cli 3.3.0 → 3.4.0

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.
Files changed (33) hide show
  1. package/LICENSE +21 -21
  2. package/client.js +664 -626
  3. package/commands/Print.js +167 -167
  4. package/commands/Validations.js +103 -103
  5. package/commands/build/build.js +40 -40
  6. package/commands/buildProduction/buildProduction.js +579 -579
  7. package/commands/bundle/bundle.js +235 -235
  8. package/commands/createComponent/VisualComponentTemplate.js +55 -55
  9. package/commands/createComponent/createComponent.js +126 -126
  10. package/commands/deleteComponent/deleteComponent.js +77 -77
  11. package/commands/doctor/doctor.js +369 -369
  12. package/commands/getComponent/getComponent.js +747 -747
  13. package/commands/init/init.js +265 -261
  14. package/commands/listComponents/listComponents.js +175 -175
  15. package/commands/startServer/startServer.js +264 -264
  16. package/commands/startServer/watchServer.js +79 -79
  17. package/commands/types/types.js +16 -9
  18. package/commands/utils/LocalCliDelegation.js +53 -53
  19. package/commands/utils/PathHelper.js +68 -68
  20. package/commands/utils/VersionChecker.js +167 -167
  21. package/commands/utils/bundling/BundleGenerator.js +2292 -2292
  22. package/commands/utils/bundling/DependencyAnalyzer.js +933 -933
  23. package/commands/utils/updateManager.js +453 -453
  24. package/package.json +46 -46
  25. package/post.js +66 -65
  26. package/tests/bundle-generator.test.js +708 -708
  27. package/tests/bundle-v2-register-output.test.js +470 -470
  28. package/tests/client-launcher-contract.test.js +211 -211
  29. package/tests/client-update-flow-contract.test.js +272 -272
  30. package/tests/dependency-analyzer.test.js +24 -24
  31. package/tests/local-cli-delegation.test.js +79 -79
  32. package/tests/update-manager-notifications.test.js +88 -88
  33. package/.github/workflows/docs-render-cicd.yml +0 -65
@@ -1,79 +1,79 @@
1
- import { test } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import fs from 'node:fs';
4
- import os from 'node:os';
5
- import path from 'node:path';
6
- import {
7
- findNearestLocalCliEntry,
8
- resolveLocalCliCandidate,
9
- shouldDelegateToLocalCli,
10
- isLocalDelegationDisabled
11
- } from '../commands/utils/LocalCliDelegation.js';
12
-
13
- test('isLocalDelegationDisabled returns true when env flag is set', () => {
14
- const env = { SLICE_NO_LOCAL_DELEGATION: '1' };
15
- assert.equal(isLocalDelegationDisabled(env), true);
16
- });
17
-
18
- test('isLocalDelegationDisabled returns false when env flag is missing', () => {
19
- const env = {};
20
- assert.equal(isLocalDelegationDisabled(env), false);
21
- });
22
-
23
- test('shouldDelegateToLocalCli is false when candidate is null', () => {
24
- assert.equal(shouldDelegateToLocalCli('/tmp/current/client.js', null), false);
25
- });
26
-
27
- test('shouldDelegateToLocalCli is false when candidate realpath equals current realpath', () => {
28
- const same = '/tmp/current/client.js';
29
- assert.equal(shouldDelegateToLocalCli(same, same), false);
30
- });
31
-
32
- test('shouldDelegateToLocalCli is true when candidate differs from current', () => {
33
- const current = '/tmp/global/client.js';
34
- const local = '/tmp/project/node_modules/slicejs-cli/client.js';
35
- assert.equal(shouldDelegateToLocalCli(current, local), true);
36
- });
37
-
38
- test('findNearestLocalCliEntry returns null when no candidate resolver hits', () => {
39
- const cwd = path.join('/tmp', 'slice-nonexistent-project');
40
- const resolver = () => null;
41
- const result = findNearestLocalCliEntry(cwd, resolver);
42
- assert.equal(result, null);
43
- });
44
-
45
- test('findNearestLocalCliEntry returns first match while traversing upward', () => {
46
- const cwd = '/repo/apps/web/src';
47
- const calls = [];
48
- const resolver = (dir) => {
49
- calls.push(dir);
50
- if (dir === '/repo/apps/web') {
51
- return '/repo/apps/web/node_modules/slicejs-cli/client.js';
52
- }
53
- return null;
54
- };
55
-
56
- const result = findNearestLocalCliEntry(cwd, resolver);
57
-
58
- assert.equal(result, '/repo/apps/web/node_modules/slicejs-cli/client.js');
59
- assert.deepEqual(calls, ['/repo/apps/web/src', '/repo/apps/web']);
60
- });
61
-
62
- test('findNearestLocalCliEntry returns null when resolver is not a function', () => {
63
- const result = findNearestLocalCliEntry('/repo/apps/web/src', null);
64
- assert.equal(result, null);
65
- });
66
-
67
- test('resolveLocalCliCandidate returns null when candidate path is a directory', () => {
68
- const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'slice-cli-delegation-'));
69
- const candidateDirectory = path.join(tempRoot, 'node_modules', 'slicejs-cli', 'client.js');
70
-
71
- fs.mkdirSync(candidateDirectory, { recursive: true });
72
-
73
- try {
74
- const result = resolveLocalCliCandidate(tempRoot);
75
- assert.equal(result, null);
76
- } finally {
77
- fs.rmSync(tempRoot, { recursive: true, force: true });
78
- }
79
- });
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import {
7
+ findNearestLocalCliEntry,
8
+ resolveLocalCliCandidate,
9
+ shouldDelegateToLocalCli,
10
+ isLocalDelegationDisabled
11
+ } from '../commands/utils/LocalCliDelegation.js';
12
+
13
+ test('isLocalDelegationDisabled returns true when env flag is set', () => {
14
+ const env = { SLICE_NO_LOCAL_DELEGATION: '1' };
15
+ assert.equal(isLocalDelegationDisabled(env), true);
16
+ });
17
+
18
+ test('isLocalDelegationDisabled returns false when env flag is missing', () => {
19
+ const env = {};
20
+ assert.equal(isLocalDelegationDisabled(env), false);
21
+ });
22
+
23
+ test('shouldDelegateToLocalCli is false when candidate is null', () => {
24
+ assert.equal(shouldDelegateToLocalCli('/tmp/current/client.js', null), false);
25
+ });
26
+
27
+ test('shouldDelegateToLocalCli is false when candidate realpath equals current realpath', () => {
28
+ const same = '/tmp/current/client.js';
29
+ assert.equal(shouldDelegateToLocalCli(same, same), false);
30
+ });
31
+
32
+ test('shouldDelegateToLocalCli is true when candidate differs from current', () => {
33
+ const current = '/tmp/global/client.js';
34
+ const local = '/tmp/project/node_modules/slicejs-cli/client.js';
35
+ assert.equal(shouldDelegateToLocalCli(current, local), true);
36
+ });
37
+
38
+ test('findNearestLocalCliEntry returns null when no candidate resolver hits', () => {
39
+ const cwd = path.join('/tmp', 'slice-nonexistent-project');
40
+ const resolver = () => null;
41
+ const result = findNearestLocalCliEntry(cwd, resolver);
42
+ assert.equal(result, null);
43
+ });
44
+
45
+ test('findNearestLocalCliEntry returns first match while traversing upward', () => {
46
+ const cwd = '/repo/apps/web/src';
47
+ const calls = [];
48
+ const resolver = (dir) => {
49
+ calls.push(dir);
50
+ if (dir === '/repo/apps/web') {
51
+ return '/repo/apps/web/node_modules/slicejs-cli/client.js';
52
+ }
53
+ return null;
54
+ };
55
+
56
+ const result = findNearestLocalCliEntry(cwd, resolver);
57
+
58
+ assert.equal(result, '/repo/apps/web/node_modules/slicejs-cli/client.js');
59
+ assert.deepEqual(calls, ['/repo/apps/web/src', '/repo/apps/web']);
60
+ });
61
+
62
+ test('findNearestLocalCliEntry returns null when resolver is not a function', () => {
63
+ const result = findNearestLocalCliEntry('/repo/apps/web/src', null);
64
+ assert.equal(result, null);
65
+ });
66
+
67
+ test('resolveLocalCliCandidate returns null when candidate path is a directory', () => {
68
+ const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'slice-cli-delegation-'));
69
+ const candidateDirectory = path.join(tempRoot, 'node_modules', 'slicejs-cli', 'client.js');
70
+
71
+ fs.mkdirSync(candidateDirectory, { recursive: true });
72
+
73
+ try {
74
+ const result = resolveLocalCliCandidate(tempRoot);
75
+ assert.equal(result, null);
76
+ } finally {
77
+ fs.rmSync(tempRoot, { recursive: true, force: true });
78
+ }
79
+ });
@@ -1,88 +1,88 @@
1
- import { test } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import Print from '../commands/Print.js';
4
- import { UpdateManager } from '../commands/utils/updateManager.js';
5
-
6
- test('notifyAvailableUpdates shows advisory output and never invokes interactive update flow', async () => {
7
- const manager = new UpdateManager();
8
- const calls = {
9
- display: 0,
10
- prompted: 0,
11
- info: [],
12
- error: []
13
- };
14
-
15
- manager.checkForUpdates = async () => ({
16
- hasUpdates: true,
17
- updates: [
18
- {
19
- name: 'slicejs-web-framework',
20
- displayName: 'Slice.js Framework',
21
- current: '2.4.3',
22
- latest: '2.5.0',
23
- type: 'framework'
24
- }
25
- ],
26
- allCurrent: false
27
- });
28
-
29
- manager.displayUpdates = () => {
30
- calls.display += 1;
31
- };
32
-
33
- manager.checkAndPromptUpdates = async () => {
34
- calls.prompted += 1;
35
- return true;
36
- };
37
-
38
- const originalInfo = Print.info;
39
- const originalError = Print.error;
40
-
41
- Print.info = (message) => calls.info.push(message);
42
- Print.error = (message) => calls.error.push(message);
43
-
44
- try {
45
- const result = await manager.notifyAvailableUpdates();
46
-
47
- assert.equal(result, true);
48
- assert.equal(calls.display, 1);
49
- assert.equal(calls.prompted, 0);
50
- assert.equal(calls.error.length, 0);
51
- assert.equal(calls.info.length, 1);
52
- assert.match(calls.info[0], /slice update/);
53
- } finally {
54
- Print.info = originalInfo;
55
- Print.error = originalError;
56
- }
57
- });
58
-
59
- test('notifyAvailableUpdates returns false and prints nothing when no updates are available', async () => {
60
- const manager = new UpdateManager();
61
- const calls = {
62
- display: 0,
63
- info: []
64
- };
65
-
66
- manager.checkForUpdates = async () => ({
67
- hasUpdates: false,
68
- updates: [],
69
- allCurrent: true
70
- });
71
-
72
- manager.displayUpdates = () => {
73
- calls.display += 1;
74
- };
75
-
76
- const originalInfo = Print.info;
77
- Print.info = (message) => calls.info.push(message);
78
-
79
- try {
80
- const result = await manager.notifyAvailableUpdates();
81
-
82
- assert.equal(result, false);
83
- assert.equal(calls.display, 0);
84
- assert.equal(calls.info.length, 0);
85
- } finally {
86
- Print.info = originalInfo;
87
- }
88
- });
1
+ import { test } from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import Print from '../commands/Print.js';
4
+ import { UpdateManager } from '../commands/utils/updateManager.js';
5
+
6
+ test('notifyAvailableUpdates shows advisory output and never invokes interactive update flow', async () => {
7
+ const manager = new UpdateManager();
8
+ const calls = {
9
+ display: 0,
10
+ prompted: 0,
11
+ info: [],
12
+ error: []
13
+ };
14
+
15
+ manager.checkForUpdates = async () => ({
16
+ hasUpdates: true,
17
+ updates: [
18
+ {
19
+ name: 'slicejs-web-framework',
20
+ displayName: 'Slice.js Framework',
21
+ current: '2.4.3',
22
+ latest: '2.5.0',
23
+ type: 'framework'
24
+ }
25
+ ],
26
+ allCurrent: false
27
+ });
28
+
29
+ manager.displayUpdates = () => {
30
+ calls.display += 1;
31
+ };
32
+
33
+ manager.checkAndPromptUpdates = async () => {
34
+ calls.prompted += 1;
35
+ return true;
36
+ };
37
+
38
+ const originalInfo = Print.info;
39
+ const originalError = Print.error;
40
+
41
+ Print.info = (message) => calls.info.push(message);
42
+ Print.error = (message) => calls.error.push(message);
43
+
44
+ try {
45
+ const result = await manager.notifyAvailableUpdates();
46
+
47
+ assert.equal(result, true);
48
+ assert.equal(calls.display, 1);
49
+ assert.equal(calls.prompted, 0);
50
+ assert.equal(calls.error.length, 0);
51
+ assert.equal(calls.info.length, 1);
52
+ assert.match(calls.info[0], /slice update/);
53
+ } finally {
54
+ Print.info = originalInfo;
55
+ Print.error = originalError;
56
+ }
57
+ });
58
+
59
+ test('notifyAvailableUpdates returns false and prints nothing when no updates are available', async () => {
60
+ const manager = new UpdateManager();
61
+ const calls = {
62
+ display: 0,
63
+ info: []
64
+ };
65
+
66
+ manager.checkForUpdates = async () => ({
67
+ hasUpdates: false,
68
+ updates: [],
69
+ allCurrent: true
70
+ });
71
+
72
+ manager.displayUpdates = () => {
73
+ calls.display += 1;
74
+ };
75
+
76
+ const originalInfo = Print.info;
77
+ Print.info = (message) => calls.info.push(message);
78
+
79
+ try {
80
+ const result = await manager.notifyAvailableUpdates();
81
+
82
+ assert.equal(result, false);
83
+ assert.equal(calls.display, 0);
84
+ assert.equal(calls.info.length, 0);
85
+ } finally {
86
+ Print.info = originalInfo;
87
+ }
88
+ });
@@ -1,65 +0,0 @@
1
- name: Docs Parse + Render CD
2
-
3
- on:
4
- pull_request:
5
- branches: [main]
6
- push:
7
- branches: [main]
8
- workflow_dispatch:
9
-
10
- permissions:
11
- contents: write
12
-
13
- jobs:
14
- docs-pipeline:
15
- runs-on: ubuntu-latest
16
-
17
- steps:
18
- - name: Checkout
19
- uses: actions/checkout@v4
20
- with:
21
- fetch-depth: 0
22
-
23
- - name: Setup Node
24
- uses: actions/setup-node@v4
25
- with:
26
- node-version: '20'
27
- cache: 'npm'
28
-
29
- - name: Install dependencies
30
- run: npm ci
31
-
32
- - name: Validate markdown docs
33
- run: npm run docs:lint-md
34
-
35
- - name: Generate documentation artifacts
36
- run: npm run docs:generate
37
-
38
- - name: Check generated changes (PR)
39
- if: github.event_name == 'pull_request'
40
- run: |
41
- if ! git diff --quiet; then
42
- echo "Generated files are out of date. Run 'npm run docs:generate' and commit changes."
43
- git status --short
44
- exit 1
45
- fi
46
-
47
- - name: Commit generated docs (main)
48
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49
- run: |
50
- if ! git diff --quiet; then
51
- git config user.name "github-actions[bot]"
52
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
53
- git add src/Components src/Styles src/routes.js
54
- git commit -m "chore(docs): auto-generate docs artifacts from markdown"
55
- git push
56
- else
57
- echo "No generated changes to commit."
58
- fi
59
-
60
- - name: Trigger Render deploy
61
- if: github.event_name == 'push' && github.ref == 'refs/heads/main' && secrets.RENDER_DEPLOY_HOOK_URL != ''
62
- run: |
63
- curl --fail --silent --show-error --request POST "$RENDER_DEPLOY_HOOK_URL"
64
- env:
65
- RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}