create-sui-dapp
Advanced tools
Comparing version 0.3.1 to 0.4.0
@@ -41,3 +41,3 @@ #!/usr/bin/env node | ||
import { APP_NAME } from "./constants.js"; | ||
import { checkGit, cloneStarter, displaySuccessMessage, promptForProjectName, } from "./utils.js"; | ||
import { checkGit, cloneStarter, displaySuccessMessage, getPackageVersion, promptForProjectName, } from "./utils.js"; | ||
var main = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -54,2 +54,3 @@ var program; | ||
.description("Install ".concat(APP_NAME, " with ease")) | ||
.version(getPackageVersion()) | ||
.arguments("[project-name]") | ||
@@ -56,0 +57,0 @@ .action(function (args) { return __awaiter(void 0, void 0, void 0, function () { |
@@ -43,2 +43,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
import { SOURCE_REPO } from "./constants.js"; | ||
@@ -67,3 +68,3 @@ export var cloneStarter = function (projectName) { return __awaiter(void 0, void 0, void 0, function () { | ||
case 6: | ||
displayErrorMessage('- PNPM is not found. Please install https://pnpm.io/installation'); | ||
displayErrorMessage("- PNPM is not found. Please install https://pnpm.io/installation"); | ||
_a.label = 7; | ||
@@ -162,2 +163,18 @@ case 7: | ||
}; | ||
export var getPackageVersion = function () { | ||
try { | ||
var packageFile = fs.readFileSync(path.join(getCliDirectory(), "../package.json"), "utf8"); | ||
var packageMeta = JSON.parse(packageFile); | ||
return packageMeta.version; | ||
} | ||
catch (e) { | ||
displayErrorMessage("Cannot read package meta-data."); | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
}; | ||
var getCliDirectory = function () { | ||
var currentFileUrl = import.meta.url; | ||
return path.dirname(decodeURI(fileURLToPath(currentFileUrl))); | ||
}; | ||
var runCommand = function (command, successMessage, errorMessage, verbose) { | ||
@@ -164,0 +181,0 @@ if (verbose === void 0) { verbose = false; } |
{ | ||
"name": "create-sui-dapp", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Command-line interface for Sui dApp Starter", | ||
@@ -18,3 +18,3 @@ "type": "module", | ||
"@types/inquirer": "^9.0.7", | ||
"@types/node": "^20.12.12", | ||
"@types/node": "^20.14.6", | ||
"typescript": "^5.4.5" | ||
@@ -26,3 +26,3 @@ }, | ||
"commander": "^12.1.0", | ||
"inquirer": "^9.2.22" | ||
"inquirer": "^9.2.23" | ||
}, | ||
@@ -29,0 +29,0 @@ "keywords": [ |
@@ -10,2 +10,3 @@ #!/usr/bin/env node | ||
displaySuccessMessage, | ||
getPackageVersion, | ||
promptForProjectName, | ||
@@ -22,2 +23,3 @@ } from "./utils.js"; | ||
.description(`Install ${APP_NAME} with ease`) | ||
.version(getPackageVersion()) | ||
.arguments("[project-name]") | ||
@@ -24,0 +26,0 @@ .action(async (args: string) => { |
@@ -7,2 +7,3 @@ import chalk from "chalk"; | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
import { SOURCE_REPO } from "./constants.js"; | ||
@@ -37,6 +38,7 @@ | ||
); | ||
} else { | ||
displayErrorMessage( | ||
"- PNPM is not found. Please install https://pnpm.io/installation" | ||
); | ||
} | ||
else { | ||
displayErrorMessage('- PNPM is not found. Please install https://pnpm.io/installation') | ||
} | ||
@@ -114,2 +116,22 @@ displaySuccessMessage("\nHappy coding!"); | ||
export const getPackageVersion = () => { | ||
try { | ||
const packageFile = fs.readFileSync( | ||
path.join(getCliDirectory(), "../package.json"), | ||
"utf8" | ||
); | ||
const packageMeta = JSON.parse(packageFile); | ||
return packageMeta.version; | ||
} catch (e) { | ||
displayErrorMessage(`Cannot read package meta-data.`); | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
}; | ||
const getCliDirectory = () => { | ||
const currentFileUrl = import.meta.url; | ||
return path.dirname(decodeURI(fileURLToPath(currentFileUrl))); | ||
}; | ||
const runCommand = ( | ||
@@ -116,0 +138,0 @@ command: string, |
20474
450
Updatedinquirer@^9.2.23