@project-ajax/create 0.0.12 → 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 +27 -18
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import fs from "fs";
|
|
|
5
5
|
import os from "os";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { parseArgs } from "util";
|
|
8
|
+
import * as prompts from "@inquirer/prompts";
|
|
8
9
|
import chalk from "chalk";
|
|
9
10
|
import { execa } from "execa";
|
|
10
11
|
import ora from "ora";
|
|
11
|
-
import prompts from "prompts";
|
|
12
12
|
run().then(() => {
|
|
13
13
|
process.exit(0);
|
|
14
14
|
}).catch((err) => {
|
|
@@ -30,29 +30,24 @@ async function run() {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
name: "directoryName",
|
|
33
|
+
let directoryName = values.directory;
|
|
34
|
+
let projectName = values.project;
|
|
35
|
+
if (!directoryName) {
|
|
36
|
+
directoryName = await safePrompt({
|
|
38
37
|
message: "Path to the new worker project:",
|
|
39
|
-
|
|
38
|
+
default: ".",
|
|
39
|
+
required: true,
|
|
40
|
+
noTTY: "Provide the path to the new project with --directory"
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
if (!
|
|
43
|
-
|
|
44
|
-
type: "text",
|
|
45
|
-
name: "projectName",
|
|
43
|
+
if (!projectName) {
|
|
44
|
+
projectName = await safePrompt({
|
|
46
45
|
message: "Project name:",
|
|
47
|
-
|
|
46
|
+
default: "my-worker",
|
|
47
|
+
required: true,
|
|
48
|
+
noTTY: "Provide the project name with --project"
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
let answers;
|
|
51
|
-
if (promptQuestions.length > 0) {
|
|
52
|
-
answers = await prompts(promptQuestions);
|
|
53
|
-
}
|
|
54
|
-
const directoryName = values.directory ?? answers?.directoryName;
|
|
55
|
-
const projectName = values.project ?? answers?.projectName;
|
|
56
51
|
if (!directoryName || !projectName) {
|
|
57
52
|
console.log(chalk.red("Cancelled."));
|
|
58
53
|
process.exit(1);
|
|
@@ -169,3 +164,17 @@ function printNextSteps(directoryName) {
|
|
|
169
164
|
`);
|
|
170
165
|
}
|
|
171
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
|
}
|