slicejs-cli 3.6.1 → 3.6.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.
@@ -32,6 +32,16 @@ async function fetchLatestVersion(packageName) {
32
32
  }
33
33
  }
34
34
 
35
+ function getRunningCliVersion() {
36
+ try {
37
+ const cliRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
38
+ const cliPkg = fs.readJsonSync(path.join(cliRoot, 'package.json'));
39
+ return typeof cliPkg.version === 'string' ? cliPkg.version : null;
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+
35
45
  async function ensurePnpmAllowBuilds(projectRoot) {
36
46
  const workspacePath = path.join(projectRoot, 'pnpm-workspace.yaml');
37
47
  const allowBuildLine = ' slicejs-cli: true';
@@ -152,6 +162,9 @@ export default async function initializeProject(options = {}) {
152
162
  let sliceBaseDir;
153
163
  try {
154
164
  latestVersion = await fetchLatestVersion('slicejs-web-framework');
165
+ const frameworkPackage = latestVersion
166
+ ? `slicejs-web-framework@${latestVersion}`
167
+ : 'slicejs-web-framework';
155
168
  const installedPkgPath = getPath(import.meta.url, 'node_modules', 'slicejs-web-framework', 'package.json');
156
169
  let installed = null;
157
170
  if (await fs.pathExists(installedPkgPath)) {
@@ -159,11 +172,7 @@ export default async function initializeProject(options = {}) {
159
172
  installed = pkg.version;
160
173
  }
161
174
  if (!installed || (latestVersion && installed !== latestVersion)) {
162
- // Install WITHOUT pinning an exact version: the package manager
163
- // resolves it under its own policies (e.g. pnpm minimumReleaseAge
164
- // quarantines versions younger than the configured age — pinning
165
- // the registry's freshest version would make resolution fail).
166
- execSync(installCommand(packageManager, 'slicejs-web-framework'), { cwd: projectRoot, stdio: 'inherit' });
175
+ execSync(installCommand(packageManager, frameworkPackage), { cwd: projectRoot, stdio: 'inherit' });
167
176
  }
168
177
  if (await fs.pathExists(installedPkgPath)) {
169
178
  const pkg = await fs.readJson(installedPkgPath);
@@ -194,13 +203,24 @@ export default async function initializeProject(options = {}) {
194
203
  const cliSpinner = ora('Installing slicejs-cli as devDependency...').start();
195
204
  try {
196
205
  const cliPkgPath = getPath(import.meta.url, 'node_modules', 'slicejs-cli', 'package.json');
197
- if (!(await fs.pathExists(cliPkgPath))) {
198
- execSync(installCommand(packageManager, 'slicejs-cli', { dev: true }), { cwd: projectRoot, stdio: 'inherit' });
206
+ const currentCliVersion = getRunningCliVersion();
207
+ const cliPackage = currentCliVersion
208
+ ? `slicejs-cli@${currentCliVersion}`
209
+ : 'slicejs-cli';
210
+
211
+ let installedCliVersion = null;
212
+ if (await fs.pathExists(cliPkgPath)) {
213
+ const pkg = await fs.readJson(cliPkgPath);
214
+ installedCliVersion = pkg.version;
215
+ }
216
+
217
+ if (!installedCliVersion || (currentCliVersion && installedCliVersion !== currentCliVersion)) {
218
+ execSync(installCommand(packageManager, cliPackage, { dev: true }), { cwd: projectRoot, stdio: 'inherit' });
199
219
  }
200
220
  cliSpinner.succeed('slicejs-cli installed locally');
201
221
  } catch (err) {
202
222
  cliSpinner.warn('Could not install slicejs-cli locally — scripts will use the global CLI');
203
- Print.info(`You can add it later with: ${installCommand(packageManager, 'slicejs-cli', { dev: true })}`);
223
+ Print.info(`You can add it later with: ${installCommand(packageManager, `slicejs-cli@${getRunningCliVersion() || 'latest'}`, { dev: true })}`);
204
224
  }
205
225
 
206
226
  // These derive from sliceBaseDir (which comes from npm install or fallback),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "3.6.1",
3
+ "version": "3.6.2",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "bin": {
@@ -34,7 +34,9 @@
34
34
  "slice:sync": "slice sync",
35
35
  "slice:version": "slice version",
36
36
  "slice:update": "slice update",
37
- "slice:types": "slice types generate"
37
+ "slice:types": "slice types generate",
38
+ "slice:doctor": "node ./node_modules/slicejs-cli/client.js doctor",
39
+ "slice:help": "node ./node_modules/slicejs-cli/client.js --help"
38
40
  },
39
41
  "keywords": [
40
42
  "framework",
@@ -69,4 +71,4 @@
69
71
  "devDependencies": {
70
72
  "@playwright/test": "^1.60.0"
71
73
  }
72
- }
74
+ }