slicejs-cli 2.7.3 → 2.7.4
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/client.js +46 -1
- package/commands/doctor/doctor.js +35 -1
- package/package.json +5 -1
- package/post.js +5 -5
package/client.js
CHANGED
|
@@ -13,7 +13,9 @@ import updateManager from "./commands/utils/updateManager.js";
|
|
|
13
13
|
import fs from "fs";
|
|
14
14
|
import path from "path";
|
|
15
15
|
import { fileURLToPath } from "url";
|
|
16
|
-
import { getConfigPath } from "./commands/utils/PathHelper.js";
|
|
16
|
+
import { getConfigPath, getProjectRoot } from "./commands/utils/PathHelper.js";
|
|
17
|
+
import { exec } from "child_process";
|
|
18
|
+
import { promisify } from "util";
|
|
17
19
|
import validations from "./commands/Validations.js";
|
|
18
20
|
import Print from "./commands/Print.js";
|
|
19
21
|
|
|
@@ -37,6 +39,49 @@ const getCategories = () => {
|
|
|
37
39
|
// Function to run version check for all commands
|
|
38
40
|
async function runWithVersionCheck(commandFunction, ...args) {
|
|
39
41
|
try {
|
|
42
|
+
const execAsync = promisify(exec);
|
|
43
|
+
await (async () => {
|
|
44
|
+
try {
|
|
45
|
+
const info = await updateManager.detectCliInstall();
|
|
46
|
+
if (info && info.type === 'global') {
|
|
47
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
48
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
49
|
+
let hasPkg = fs.existsSync(pkgPath);
|
|
50
|
+
if (!hasPkg) {
|
|
51
|
+
const { confirmInit } = await inquirer.prompt([
|
|
52
|
+
{
|
|
53
|
+
type: 'confirm',
|
|
54
|
+
name: 'confirmInit',
|
|
55
|
+
message: 'No package.json found. Initialize npm in this project now?',
|
|
56
|
+
default: true
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
if (confirmInit) {
|
|
60
|
+
await execAsync('npm init -y', { cwd: projectRoot });
|
|
61
|
+
hasPkg = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (hasPkg) {
|
|
65
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
66
|
+
const hasFramework = pkg.dependencies?.['slicejs-web-framework'];
|
|
67
|
+
if (!hasFramework) {
|
|
68
|
+
const { confirm } = await inquirer.prompt([
|
|
69
|
+
{
|
|
70
|
+
type: 'confirm',
|
|
71
|
+
name: 'confirm',
|
|
72
|
+
message: 'slicejs-web-framework is not installed in this project. Install it now?',
|
|
73
|
+
default: true
|
|
74
|
+
}
|
|
75
|
+
]);
|
|
76
|
+
if (confirm) {
|
|
77
|
+
await updateManager.updatePackage('slicejs-web-framework');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch {}
|
|
83
|
+
})();
|
|
84
|
+
|
|
40
85
|
const updateInfo = await updateManager.checkForUpdates();
|
|
41
86
|
if (updateInfo && updateInfo.hasUpdates) {
|
|
42
87
|
await updateManager.checkAndPromptUpdates({});
|
|
@@ -5,6 +5,9 @@ import { createServer } from 'net';
|
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import Table from 'cli-table3';
|
|
7
7
|
import Print from '../Print.js';
|
|
8
|
+
import inquirer from 'inquirer';
|
|
9
|
+
import { exec } from 'child_process';
|
|
10
|
+
import { promisify } from 'util';
|
|
8
11
|
import { getProjectRoot, getSrcPath, getApiPath, getConfigPath, getPath } from '../utils/PathHelper.js';
|
|
9
12
|
|
|
10
13
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -173,7 +176,10 @@ async function checkDependencies() {
|
|
|
173
176
|
return {
|
|
174
177
|
warn: true,
|
|
175
178
|
message: `Missing dependencies: ${missing.join(', ')}`,
|
|
176
|
-
suggestion: '
|
|
179
|
+
suggestion: missing.includes('slicejs-web-framework')
|
|
180
|
+
? 'Run "npm install slicejs-web-framework@latest" in your project'
|
|
181
|
+
: 'Run "npm install -D slicejs-cli@latest" in your project',
|
|
182
|
+
missing
|
|
177
183
|
};
|
|
178
184
|
}
|
|
179
185
|
} catch (error) {
|
|
@@ -313,6 +319,34 @@ export default async function runDiagnostics() {
|
|
|
313
319
|
Print.newLine();
|
|
314
320
|
Print.separator();
|
|
315
321
|
|
|
322
|
+
const depsResult = results.find(r => r.name === 'Dependencies');
|
|
323
|
+
if (depsResult && depsResult.warn && Array.isArray(depsResult.missing) && depsResult.missing.length > 0) {
|
|
324
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
325
|
+
const execAsync = promisify(exec);
|
|
326
|
+
const { confirmInstall } = await inquirer.prompt([
|
|
327
|
+
{
|
|
328
|
+
type: 'confirm',
|
|
329
|
+
name: 'confirmInstall',
|
|
330
|
+
message: `Install missing dependencies in this project now? (${depsResult.missing.join(', ')})`,
|
|
331
|
+
default: true
|
|
332
|
+
}
|
|
333
|
+
]);
|
|
334
|
+
if (confirmInstall) {
|
|
335
|
+
for (const pkg of depsResult.missing) {
|
|
336
|
+
try {
|
|
337
|
+
const cmd = pkg === 'slicejs-cli'
|
|
338
|
+
? 'npm install -D slicejs-cli@latest'
|
|
339
|
+
: 'npm install slicejs-web-framework@latest';
|
|
340
|
+
Print.info(`Installing ${pkg}...`);
|
|
341
|
+
await execAsync(cmd, { cwd: projectRoot });
|
|
342
|
+
Print.success(`${pkg} installed`);
|
|
343
|
+
} catch (e) {
|
|
344
|
+
Print.error(`Installing ${pkg}: ${e.message}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
316
350
|
if (issues === 0 && warnings === 0) {
|
|
317
351
|
Print.success('All checks passed! 🎉');
|
|
318
352
|
Print.info('Your Slice.js project is correctly configured');
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "slicejs-cli",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.4",
|
|
4
4
|
"description": "Command client for developing web applications with Slice.js framework",
|
|
5
5
|
"main": "client.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"slice": "./client.js"
|
|
8
8
|
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/vkneider/slicejs-cli.git"
|
|
12
|
+
},
|
|
9
13
|
"scripts": {
|
|
10
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
15
|
"postinstall": "node post.js"
|
package/post.js
CHANGED
|
@@ -12,14 +12,14 @@ const targetRoot = initCwd || path.resolve(__dirname, '../../');
|
|
|
12
12
|
const projectPackageJsonPath = path.join(targetRoot, 'package.json');
|
|
13
13
|
|
|
14
14
|
if (isGlobal) {
|
|
15
|
-
console.log('ℹ️
|
|
16
|
-
console.log('
|
|
15
|
+
console.log('ℹ️ Global installation of slicejs-cli detected.');
|
|
16
|
+
console.log(' Skipping scripts setup. Use the binary directly:');
|
|
17
17
|
console.log(' slice dev');
|
|
18
18
|
console.log(' slice get Button');
|
|
19
19
|
process.exit(0);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
console.log('ℹ️
|
|
23
|
-
console.log('
|
|
24
|
-
console.log('
|
|
22
|
+
console.log('ℹ️ Local installation of slicejs-cli detected.');
|
|
23
|
+
console.log(' Skipping automatic scripts setup in postinstall.');
|
|
24
|
+
console.log(' Use "slice init" to configure project scripts.');
|
|
25
25
|
process.exit(0);
|