@jairodri/huckleberry-cli 1.0.0 → 1.0.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/package.json +1 -1
- package/src/cli.js +9 -7
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -8,16 +8,18 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
8
8
|
const ROOT = join(__dirname, "..");
|
|
9
9
|
const PACKAGE_ROOT = ROOT;
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const PKG = JSON.parse(
|
|
12
12
|
readFileSync(join(PACKAGE_ROOT, "package.json"), "utf-8")
|
|
13
|
-
)
|
|
13
|
+
);
|
|
14
|
+
const VERSION = PKG.version;
|
|
15
|
+
const PKG_NAME = PKG.name;
|
|
14
16
|
|
|
15
|
-
const commands = { install, update, "install-pack": installPack, interview: runInterview, help, version: () => console.log(
|
|
17
|
+
const commands = { install, update, "install-pack": installPack, interview: runInterview, help, version: () => console.log(`${PKG_NAME} v${VERSION}`) };
|
|
16
18
|
|
|
17
19
|
export async function run(args) {
|
|
18
20
|
const cmd = args[0];
|
|
19
21
|
if (!cmd || cmd === "--help" || cmd === "-h") return help();
|
|
20
|
-
if (cmd === "--version" || cmd === "-v") return console.log(
|
|
22
|
+
if (cmd === "--version" || cmd === "-v") return console.log(`${PKG_NAME} v${VERSION}`);
|
|
21
23
|
const handler = commands[cmd];
|
|
22
24
|
if (!handler) {
|
|
23
25
|
console.error(`Unknown command: ${cmd}\nRun 'huckleberry help' for usage.`);
|
|
@@ -171,10 +173,10 @@ async function install() {
|
|
|
171
173
|
async function update() {
|
|
172
174
|
console.log(`\n Updating Huckleberry...\n`);
|
|
173
175
|
try {
|
|
174
|
-
execSync(
|
|
175
|
-
console.log(` ✓
|
|
176
|
+
execSync(`npm update -g ${PKG_NAME}`, { stdio: "inherit" });
|
|
177
|
+
console.log(` ✓ ${PKG_NAME} updated`);
|
|
176
178
|
} catch {
|
|
177
|
-
console.error(` ⚠
|
|
179
|
+
console.error(` ⚠ ${PKG_NAME} update failed. Try: npm install -g ${PKG_NAME}@latest\n`);
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
// Update Inkstone independently
|