@ijuantm/simpl-addon 1.1.2 → 1.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/install.js +33 -8
- package/package.json +5 -1
package/install.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
@@ -56,6 +56,19 @@ const downloadFile = (url, dest) => new Promise((resolve, reject) => {
|
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
const getSimplVersion = () => {
|
|
60
|
+
const simplFile = path.join(process.cwd(), '.simpl');
|
|
61
|
+
|
|
62
|
+
if (!fs.existsSync(simplFile)) throw new Error('Not a Simpl project. Missing .simpl file in current directory.');
|
|
63
|
+
|
|
64
|
+
const content = fs.readFileSync(simplFile, 'utf8');
|
|
65
|
+
const config = JSON.parse(content);
|
|
66
|
+
|
|
67
|
+
if (!config.version) throw new Error('Invalid .simpl file: missing version field');
|
|
68
|
+
|
|
69
|
+
return config.version;
|
|
70
|
+
};
|
|
71
|
+
|
|
59
72
|
const showHelp = () => {
|
|
60
73
|
console.log();
|
|
61
74
|
log(` ╭${'─'.repeat(62)}╮`);
|
|
@@ -63,13 +76,12 @@ const showHelp = () => {
|
|
|
63
76
|
log(` ╰${'─'.repeat(62)}╯`);
|
|
64
77
|
console.log();
|
|
65
78
|
log(` ${COLORS.bold}Usage:${COLORS.reset}`, 'blue');
|
|
66
|
-
log(` ${COLORS.dim}npx @ijuantm/simpl-addon <addon-name
|
|
67
|
-
log(` ${COLORS.dim}npx @ijuantm/simpl-addon --list
|
|
79
|
+
log(` ${COLORS.dim}npx @ijuantm/simpl-addon <addon-name>${COLORS.reset}`);
|
|
80
|
+
log(` ${COLORS.dim}npx @ijuantm/simpl-addon --list${COLORS.reset}`);
|
|
68
81
|
log(` ${COLORS.dim}npx @ijuantm/simpl-addon --help${COLORS.reset}`);
|
|
69
82
|
console.log();
|
|
70
83
|
log(` ${COLORS.bold}Arguments:${COLORS.reset}`, 'blue');
|
|
71
84
|
log(` ${COLORS.dim}addon-name${COLORS.reset} Name of the add-on to install`);
|
|
72
|
-
log(` ${COLORS.dim}version${COLORS.reset} Framework version (default: latest)`);
|
|
73
85
|
console.log();
|
|
74
86
|
log(` ${COLORS.bold}Commands:${COLORS.reset}`, 'blue');
|
|
75
87
|
log(` ${COLORS.dim}--list, -l${COLORS.reset} List all available add-ons`);
|
|
@@ -77,9 +89,12 @@ const showHelp = () => {
|
|
|
77
89
|
console.log();
|
|
78
90
|
log(` ${COLORS.bold}Examples:${COLORS.reset}`, 'blue');
|
|
79
91
|
log(` ${COLORS.dim}npx @ijuantm/simpl-addon auth${COLORS.reset}`);
|
|
80
|
-
log(` ${COLORS.dim}npx @ijuantm/simpl-addon auth 1.5.0${COLORS.reset}`);
|
|
81
92
|
log(` ${COLORS.dim}npx @ijuantm/simpl-addon --list${COLORS.reset}`);
|
|
82
93
|
console.log();
|
|
94
|
+
log(` ${COLORS.bold}Note:${COLORS.reset}`, 'blue');
|
|
95
|
+
log(` Run this command from the root of your Simpl project.`);
|
|
96
|
+
log(` The add-on version will match your Simpl framework version.`);
|
|
97
|
+
console.log();
|
|
83
98
|
};
|
|
84
99
|
|
|
85
100
|
const listAddons = async (version) => {
|
|
@@ -92,7 +107,7 @@ const listAddons = async (version) => {
|
|
|
92
107
|
|
|
93
108
|
try {
|
|
94
109
|
const response = await fetchUrl(`${CDN_BASE}/${version}/add-ons/list.json`);
|
|
95
|
-
const addons = JSON.parse(response)['add-ons'];
|
|
110
|
+
const addons = JSON.parse(String(response))['add-ons'];
|
|
96
111
|
|
|
97
112
|
console.log();
|
|
98
113
|
|
|
@@ -353,15 +368,25 @@ const main = async () => {
|
|
|
353
368
|
process.exit(0);
|
|
354
369
|
}
|
|
355
370
|
|
|
371
|
+
let version;
|
|
372
|
+
|
|
373
|
+
try {
|
|
374
|
+
version = getSimplVersion();
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.log();
|
|
377
|
+
log(` ${COLORS.red}✗${COLORS.reset} ${error.message}`, 'red');
|
|
378
|
+
console.log();
|
|
379
|
+
|
|
380
|
+
process.exit(1);
|
|
381
|
+
}
|
|
382
|
+
|
|
356
383
|
if (firstArg === '--list' || firstArg === '-l') {
|
|
357
|
-
const version = args[1] || 'latest';
|
|
358
384
|
await listAddons(version);
|
|
359
385
|
|
|
360
386
|
process.exit(0);
|
|
361
387
|
}
|
|
362
388
|
|
|
363
389
|
const addonName = firstArg;
|
|
364
|
-
const version = args[1] || 'latest';
|
|
365
390
|
|
|
366
391
|
console.log();
|
|
367
392
|
log(` ╭${'─'.repeat(62)}╮`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ijuantm/simpl-addon",
|
|
3
|
-
"version": "1.1.2",
|
|
4
3
|
"description": "CLI tool to install Simpl framework add-ons.",
|
|
4
|
+
"version": "1.2.1",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"link": "npm link",
|
|
7
|
+
"unlink": "npm unlink -g @ijuantm/simpl-addon"
|
|
8
|
+
},
|
|
5
9
|
"main": "install.js",
|
|
6
10
|
"bin": {
|
|
7
11
|
"simpl-addon": "install.js"
|