@project-ajax/create 0.0.11 → 0.0.13
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/dist/index.js +44 -13
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import os from "os";
|
|
6
6
|
import path from "path";
|
|
7
|
+
import { parseArgs } from "util";
|
|
8
|
+
import * as prompts from "@inquirer/prompts";
|
|
7
9
|
import chalk from "chalk";
|
|
8
10
|
import { execa } from "execa";
|
|
9
11
|
import ora from "ora";
|
|
10
|
-
import prompts from "prompts";
|
|
11
12
|
run().then(() => {
|
|
12
13
|
process.exit(0);
|
|
13
14
|
}).catch((err) => {
|
|
@@ -17,20 +18,36 @@ ${err.message}`));
|
|
|
17
18
|
});
|
|
18
19
|
async function run() {
|
|
19
20
|
console.log(chalk.bold.cyan("\n\u{1F680} Create a new Project Ajax worker\n"));
|
|
20
|
-
const {
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const { values } = parseArgs({
|
|
22
|
+
options: {
|
|
23
|
+
directory: {
|
|
24
|
+
type: "string",
|
|
25
|
+
short: "d"
|
|
26
|
+
},
|
|
27
|
+
project: {
|
|
28
|
+
type: "string",
|
|
29
|
+
short: "p"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
let directoryName = values.directory;
|
|
34
|
+
let projectName = values.project;
|
|
35
|
+
if (!directoryName) {
|
|
36
|
+
directoryName = await safePrompt({
|
|
24
37
|
message: "Path to the new worker project:",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
default: ".",
|
|
39
|
+
required: true,
|
|
40
|
+
noTTY: "Provide the path to the new project with --directory"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (!projectName) {
|
|
44
|
+
projectName = await safePrompt({
|
|
30
45
|
message: "Project name:",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
default: "my-worker",
|
|
47
|
+
required: true,
|
|
48
|
+
noTTY: "Provide the project name with --project"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
34
51
|
if (!directoryName || !projectName) {
|
|
35
52
|
console.log(chalk.red("Cancelled."));
|
|
36
53
|
process.exit(1);
|
|
@@ -147,3 +164,17 @@ function printNextSteps(directoryName) {
|
|
|
147
164
|
`);
|
|
148
165
|
}
|
|
149
166
|
}
|
|
167
|
+
function safePrompt(config) {
|
|
168
|
+
if (!process.stdin.isTTY) {
|
|
169
|
+
console.error(chalk.red(config.noTTY));
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
return prompts.input(config).catch((err) => {
|
|
173
|
+
if (err instanceof Error && err.name === "ExitPromptError") {
|
|
174
|
+
console.log(chalk.red("\u{1F44B} Goodbye!"));
|
|
175
|
+
process.exit(1);
|
|
176
|
+
} else {
|
|
177
|
+
throw err;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@project-ajax/create",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Initialize a new Notion Project Ajax extensions repo.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-ajax": "dist/index.js"
|
|
@@ -25,14 +25,13 @@
|
|
|
25
25
|
"dist/"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@inquirer/prompts": "^8.0.1",
|
|
28
29
|
"chalk": "^5.3.0",
|
|
29
30
|
"execa": "^8.0.0",
|
|
30
|
-
"ora": "^8.0.1"
|
|
31
|
-
"prompts": "^2.4.2"
|
|
31
|
+
"ora": "^8.0.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.19.0",
|
|
35
|
-
"@types/prompts": "^2.4.9",
|
|
36
35
|
"tsup": "^8.5.0",
|
|
37
36
|
"typescript": "^5.9.3"
|
|
38
37
|
}
|