create-gato-app 0.1.1 → 0.2.0
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/README.md +67 -57
- package/dist/args.js +199 -84
- package/dist/clack-ui.js +86 -0
- package/dist/cli.js +58 -36
- package/dist/compare.js +6 -0
- package/dist/compose-ports.js +137 -0
- package/dist/delegate.js +20 -10
- package/dist/env-file.js +54 -0
- package/dist/github.js +28 -0
- package/dist/index.js +9 -0
- package/dist/kit-engines.js +39 -0
- package/dist/kit-modules.js +66 -0
- package/dist/next-steps.js +49 -0
- package/dist/node-version.js +19 -1
- package/dist/port-probe.js +31 -0
- package/dist/questions.js +176 -0
- package/dist/ui.js +1 -0
- package/dist/validate.js +39 -0
- package/dist/wizard.js +233 -0
- package/package.json +3 -2
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { withRequired } from "./kit-modules.js";
|
|
2
|
+
import { adminEmailError, envValueError, titleError } from "./validate.js";
|
|
3
|
+
export const LOCAL_MINIO_ENDPOINT = "http://localhost:9000";
|
|
4
|
+
export const LOCAL_MINIO_KEY = "minioadmin";
|
|
5
|
+
export const HTTP_URL_ERROR = "expected an http(s) URL";
|
|
6
|
+
export class CancelledError extends Error {
|
|
7
|
+
name = "CancelledError";
|
|
8
|
+
}
|
|
9
|
+
const UPLOADS = "uploads";
|
|
10
|
+
const HTTP_URL = /^https?:\/\/\S+$/;
|
|
11
|
+
export function isHttpUrl(value) {
|
|
12
|
+
return HTTP_URL.test(value);
|
|
13
|
+
}
|
|
14
|
+
export function displayName(slug) {
|
|
15
|
+
return slug
|
|
16
|
+
.split("-")
|
|
17
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
18
|
+
.join(" ");
|
|
19
|
+
}
|
|
20
|
+
function orUndefined(message) {
|
|
21
|
+
return message ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
async function askModules({ args, prompter, ask }, modules) {
|
|
24
|
+
if (args.modules !== null) {
|
|
25
|
+
return withRequired(args.modules, modules);
|
|
26
|
+
}
|
|
27
|
+
if (!ask || modules.length === 0) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
const chosen = await prompter.multiselect({
|
|
31
|
+
message: "Modules (space to toggle, enter to confirm)",
|
|
32
|
+
options: modules.map((module) => ({
|
|
33
|
+
value: module.name,
|
|
34
|
+
label: module.name,
|
|
35
|
+
hint: module.description,
|
|
36
|
+
})),
|
|
37
|
+
initialValues: [],
|
|
38
|
+
});
|
|
39
|
+
return withRequired(chosen, modules);
|
|
40
|
+
}
|
|
41
|
+
async function askLocales({ args, prompter, ask }) {
|
|
42
|
+
if (args.locales !== null) {
|
|
43
|
+
return args.locales;
|
|
44
|
+
}
|
|
45
|
+
if (!ask) {
|
|
46
|
+
return ["pl", "en"];
|
|
47
|
+
}
|
|
48
|
+
const english = await prompter.confirm({
|
|
49
|
+
message: "Add English? Polish is always included.",
|
|
50
|
+
initialValue: true,
|
|
51
|
+
});
|
|
52
|
+
return english ? ["pl", "en"] : ["pl"];
|
|
53
|
+
}
|
|
54
|
+
async function askTitle({ args, prompter, ask }, slug) {
|
|
55
|
+
if (args.title !== null) {
|
|
56
|
+
return args.title;
|
|
57
|
+
}
|
|
58
|
+
if (!ask) {
|
|
59
|
+
return displayName(slug);
|
|
60
|
+
}
|
|
61
|
+
const title = await prompter.text({
|
|
62
|
+
message: "Display name",
|
|
63
|
+
defaultValue: displayName(slug),
|
|
64
|
+
placeholder: displayName(slug),
|
|
65
|
+
validate: (value) => orUndefined(titleError(value)),
|
|
66
|
+
});
|
|
67
|
+
return title.trim() || displayName(slug);
|
|
68
|
+
}
|
|
69
|
+
async function askAdminEmail({ args, prompter, ask, }) {
|
|
70
|
+
if (args.adminEmail !== null) {
|
|
71
|
+
return args.adminEmail;
|
|
72
|
+
}
|
|
73
|
+
if (!ask) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const email = (await prompter.text({
|
|
77
|
+
message: "First admin's email (empty to skip)",
|
|
78
|
+
defaultValue: "",
|
|
79
|
+
validate: (value) => value.trim() === ""
|
|
80
|
+
? undefined
|
|
81
|
+
: orUndefined(adminEmailError(value.trim())),
|
|
82
|
+
})).trim();
|
|
83
|
+
return email === "" ? null : email;
|
|
84
|
+
}
|
|
85
|
+
async function askEndpoint({ args, prompter, ask }) {
|
|
86
|
+
if (args.s3Endpoint !== null) {
|
|
87
|
+
return args.s3Endpoint;
|
|
88
|
+
}
|
|
89
|
+
if (!ask) {
|
|
90
|
+
return LOCAL_MINIO_ENDPOINT;
|
|
91
|
+
}
|
|
92
|
+
const endpoint = await prompter.text({
|
|
93
|
+
message: `S3 endpoint (${LOCAL_MINIO_ENDPOINT} = local MinIO started with Docker)`,
|
|
94
|
+
defaultValue: LOCAL_MINIO_ENDPOINT,
|
|
95
|
+
placeholder: LOCAL_MINIO_ENDPOINT,
|
|
96
|
+
validate: (value) => value.trim() === "" || isHttpUrl(value.trim())
|
|
97
|
+
? undefined
|
|
98
|
+
: `S3 endpoint: ${HTTP_URL_ERROR}`,
|
|
99
|
+
});
|
|
100
|
+
return endpoint.trim() || LOCAL_MINIO_ENDPOINT;
|
|
101
|
+
}
|
|
102
|
+
async function askS3(context) {
|
|
103
|
+
const { args, prompter } = context;
|
|
104
|
+
const endpoint = await askEndpoint(context);
|
|
105
|
+
const localMinio = endpoint === LOCAL_MINIO_ENDPOINT;
|
|
106
|
+
let accessKeyId = args.s3AccessKeyId;
|
|
107
|
+
let secretAccessKey = args.s3SecretAccessKey;
|
|
108
|
+
if (localMinio) {
|
|
109
|
+
accessKeyId ??= LOCAL_MINIO_KEY;
|
|
110
|
+
secretAccessKey ??= LOCAL_MINIO_KEY;
|
|
111
|
+
}
|
|
112
|
+
accessKeyId ??= await prompter.text({
|
|
113
|
+
message: "S3 access key id",
|
|
114
|
+
defaultValue: "",
|
|
115
|
+
validate: (value) => orUndefined(envValueError("S3 access key id", value)),
|
|
116
|
+
});
|
|
117
|
+
secretAccessKey ??= await prompter.password({
|
|
118
|
+
message: "S3 secret access key",
|
|
119
|
+
validate: (value) => orUndefined(envValueError("S3 secret access key", value)),
|
|
120
|
+
});
|
|
121
|
+
return { provider: "s3", endpoint, accessKeyId, secretAccessKey, localMinio };
|
|
122
|
+
}
|
|
123
|
+
async function askStorage(context, modules) {
|
|
124
|
+
if (!modules.includes(UPLOADS)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const { args, prompter, ask } = context;
|
|
128
|
+
let provider = args.storage;
|
|
129
|
+
if (provider === null) {
|
|
130
|
+
provider = ask
|
|
131
|
+
? await prompter.select({
|
|
132
|
+
message: "File storage for uploads",
|
|
133
|
+
options: [
|
|
134
|
+
{
|
|
135
|
+
value: "local",
|
|
136
|
+
label: "local",
|
|
137
|
+
hint: "files on the server's disk",
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
value: "s3",
|
|
141
|
+
label: "s3",
|
|
142
|
+
hint: "S3-compatible storage: local MinIO, AWS, R2, …",
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
initialValue: "local",
|
|
146
|
+
})
|
|
147
|
+
: "local";
|
|
148
|
+
}
|
|
149
|
+
return provider === "s3" ? askS3(context) : { provider: "local" };
|
|
150
|
+
}
|
|
151
|
+
async function askSetup({ args, prompter, ask }) {
|
|
152
|
+
if (!args.install || !args.docker) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
if (args.setup || !ask) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return prompter.confirm({
|
|
159
|
+
message: "Start the database with Docker, run migrations and create the admin now?",
|
|
160
|
+
initialValue: true,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
export async function collectAnswers(input) {
|
|
164
|
+
const context = {
|
|
165
|
+
args: input.args,
|
|
166
|
+
prompter: input.prompter,
|
|
167
|
+
ask: !input.args.yes,
|
|
168
|
+
};
|
|
169
|
+
const modules = await askModules(context, input.modules);
|
|
170
|
+
const locales = await askLocales(context);
|
|
171
|
+
const title = await askTitle(context, input.slug);
|
|
172
|
+
const adminEmail = await askAdminEmail(context);
|
|
173
|
+
const storage = await askStorage(context, modules);
|
|
174
|
+
const setup = await askSetup(context);
|
|
175
|
+
return { modules, locales, title, adminEmail, storage, setup };
|
|
176
|
+
}
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/validate.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const TITLE_MAX_LENGTH = 60;
|
|
2
|
+
export const EMAIL_MAX_LENGTH = 254;
|
|
3
|
+
const TITLE_FORBIDDEN_CHARACTERS = new Set(['"', "\\", "<", ">", "$", "`"]);
|
|
4
|
+
const FIRST_PRINTABLE = 0x20;
|
|
5
|
+
const DELETE = 0x7f;
|
|
6
|
+
function hasForbiddenCharacter(title) {
|
|
7
|
+
return Array.from(title).some((character) => {
|
|
8
|
+
const code = character.charCodeAt(0);
|
|
9
|
+
return (code < FIRST_PRINTABLE ||
|
|
10
|
+
code === DELETE ||
|
|
11
|
+
TITLE_FORBIDDEN_CHARACTERS.has(character));
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const EMAIL_PATTERN = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)+$/;
|
|
15
|
+
const ENV_VALUE_FORBIDDEN = /[\s"'\\#$`]/;
|
|
16
|
+
export function titleError(title) {
|
|
17
|
+
const trimmed = title.trim();
|
|
18
|
+
if (trimmed.length === 0 ||
|
|
19
|
+
trimmed.length > TITLE_MAX_LENGTH ||
|
|
20
|
+
hasForbiddenCharacter(title)) {
|
|
21
|
+
return `Title: use 1-${TITLE_MAX_LENGTH} characters without quotes, backslashes, <, >, $, backticks or control characters`;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
export function adminEmailError(email) {
|
|
26
|
+
if (email.length > EMAIL_MAX_LENGTH || !EMAIL_PATTERN.test(email)) {
|
|
27
|
+
return "Admin email: expected an address like admin@example.com";
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
export function envValueError(label, value) {
|
|
32
|
+
if (value === "") {
|
|
33
|
+
return `${label}: required`;
|
|
34
|
+
}
|
|
35
|
+
if (ENV_VALUE_FORBIDDEN.test(value)) {
|
|
36
|
+
return `${label}: no spaces, quotes, backslashes, #, $ or backticks`;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
package/dist/wizard.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { chmod, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { basename, join } from "node:path";
|
|
3
|
+
import { busyPortsReport, portSettings, publishedPorts, suggestFreePort, } from "./compose-ports.js";
|
|
4
|
+
import { gatoCreateCommand } from "./delegate.js";
|
|
5
|
+
import { randomSuffix, setEnvValues, SUFFIX_LENGTH, wizardEnvValues, } from "./env-file.js";
|
|
6
|
+
import { readKitModules } from "./kit-modules.js";
|
|
7
|
+
import { displayDir, nextSteps } from "./next-steps.js";
|
|
8
|
+
import { collectAnswers } from "./questions.js";
|
|
9
|
+
const OUTPUT_TAIL_LINES = 40;
|
|
10
|
+
const ENV_LINE = /^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/;
|
|
11
|
+
const S3_PROFILE = "s3";
|
|
12
|
+
function tail(result) {
|
|
13
|
+
const output = `${result.stderr}\n${result.stdout}`.trim();
|
|
14
|
+
return output.split("\n").slice(-OUTPUT_TAIL_LINES).join("\n");
|
|
15
|
+
}
|
|
16
|
+
async function runQuiet({ deps, projectDir }, command, args) {
|
|
17
|
+
try {
|
|
18
|
+
return await deps.spawn(command, args, { cwd: projectDir, stdio: "pipe" });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
22
|
+
return { code: 127, stdout: "", stderr: detail };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function envEntries(text) {
|
|
26
|
+
const entries = {};
|
|
27
|
+
for (const line of text.split(/\r?\n/)) {
|
|
28
|
+
const match = ENV_LINE.exec(line);
|
|
29
|
+
if (match) {
|
|
30
|
+
entries[match[1]] = match[2];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return entries;
|
|
34
|
+
}
|
|
35
|
+
async function assemble(context, args, kitDir, answers) {
|
|
36
|
+
const { deps, projectDir } = context;
|
|
37
|
+
const { command, args: commandArgs } = gatoCreateCommand({
|
|
38
|
+
nodePath: deps.nodePath,
|
|
39
|
+
gatoBin: deps.gatoBin,
|
|
40
|
+
kitDir,
|
|
41
|
+
projectDir,
|
|
42
|
+
answers,
|
|
43
|
+
cliSource: args.cliSource,
|
|
44
|
+
});
|
|
45
|
+
const result = await deps.ui.task("Assembling the project", () => deps.spawn(command, commandArgs, { cwd: deps.cwd, stdio: "pipe" }));
|
|
46
|
+
if (result.code !== 0) {
|
|
47
|
+
throw new Error(`Assembling the project failed (gato create exited with ${result.code}):\n${tail(result)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function writeWizardEnv(context, answers) {
|
|
51
|
+
const envPath = join(context.projectDir, ".env");
|
|
52
|
+
const existing = await readFile(envPath, "utf8");
|
|
53
|
+
const text = setEnvValues(existing, wizardEnvValues({
|
|
54
|
+
existing,
|
|
55
|
+
slug: basename(context.projectDir),
|
|
56
|
+
suffix: randomSuffix(context.deps.randomBytes(SUFFIX_LENGTH)),
|
|
57
|
+
storage: answers.storage,
|
|
58
|
+
}));
|
|
59
|
+
await writeFile(envPath, text, { mode: 0o600 });
|
|
60
|
+
await chmod(envPath, 0o600);
|
|
61
|
+
return text;
|
|
62
|
+
}
|
|
63
|
+
async function busyPorts(deps, ports) {
|
|
64
|
+
const busy = [];
|
|
65
|
+
for (const port of ports) {
|
|
66
|
+
if (await deps.isPortBusy(port.port)) {
|
|
67
|
+
busy.push(port);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return busy;
|
|
71
|
+
}
|
|
72
|
+
async function reportBusyPorts(deps, busy, ports, envText) {
|
|
73
|
+
const taken = ports.map((port) => port.port);
|
|
74
|
+
const free = new Map();
|
|
75
|
+
for (const { port } of busy) {
|
|
76
|
+
const suggestion = await suggestFreePort(port, deps.isPortBusy, taken);
|
|
77
|
+
free.set(port, suggestion);
|
|
78
|
+
if (suggestion !== null) {
|
|
79
|
+
taken.push(suggestion);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
deps.error(busyPortsReport(busy, portSettings({ busy, free, envText })).join("\n"));
|
|
83
|
+
}
|
|
84
|
+
async function startDocker(context, envText, profiles) {
|
|
85
|
+
const { deps, projectDir } = context;
|
|
86
|
+
const compose = await readFile(join(projectDir, "docker-compose.yml"), "utf8");
|
|
87
|
+
const ports = publishedPorts(compose, {
|
|
88
|
+
profiles,
|
|
89
|
+
env: { ...envEntries(envText), ...deps.env },
|
|
90
|
+
});
|
|
91
|
+
const busy = await busyPorts(deps, ports);
|
|
92
|
+
if (busy.length > 0) {
|
|
93
|
+
await reportBusyPorts(deps, busy, ports, envText);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const info = await runQuiet(context, "docker", ["info"]);
|
|
97
|
+
if (info.code !== 0) {
|
|
98
|
+
deps.error("Docker is not available (docker info failed), so the database was not started. Start Docker and run the remaining steps below.");
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const profileArgs = profiles.flatMap((profile) => ["--profile", profile]);
|
|
102
|
+
const up = await deps.ui.task("Starting Docker services", () => runQuiet(context, "docker", [
|
|
103
|
+
"compose",
|
|
104
|
+
...profileArgs,
|
|
105
|
+
"up",
|
|
106
|
+
"-d",
|
|
107
|
+
"--wait",
|
|
108
|
+
]));
|
|
109
|
+
if (up.code !== 0) {
|
|
110
|
+
deps.error(`docker compose up failed:\n${tail(up)}`);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
async function install(context) {
|
|
116
|
+
const result = await context.deps.ui.task("Installing dependencies (npm install)", () => runQuiet(context, "npm", ["install"]));
|
|
117
|
+
if (result.code !== 0) {
|
|
118
|
+
context.deps.error(`npm install failed:\n${tail(result)}`);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
async function migrate(context) {
|
|
124
|
+
const result = await context.deps.ui.task("Creating the database schema (prisma migrate dev)", () => runQuiet(context, "npx", ["prisma", "migrate", "dev", "--name", "init"]));
|
|
125
|
+
if (result.code !== 0) {
|
|
126
|
+
context.deps.error(`prisma migrate dev failed:\n${tail(result)}`);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
async function createAdmin(context, email) {
|
|
132
|
+
const { deps, projectDir } = context;
|
|
133
|
+
deps.ui.step(`Creating the first admin (${email})`);
|
|
134
|
+
let code;
|
|
135
|
+
try {
|
|
136
|
+
code = (await deps.spawn("npm", ["run", "admin:create", "--", "--email", email], {
|
|
137
|
+
cwd: projectDir,
|
|
138
|
+
stdio: "inherit",
|
|
139
|
+
})).code;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
deps.error(`admin:create failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (code !== 0) {
|
|
146
|
+
deps.error(`admin:create failed (exit ${code}).`);
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
async function commit(context, version) {
|
|
152
|
+
const add = await runQuiet(context, "git", ["add", "-A"]);
|
|
153
|
+
const result = add.code === 0
|
|
154
|
+
? await runQuiet(context, "git", [
|
|
155
|
+
"commit",
|
|
156
|
+
"-q",
|
|
157
|
+
"--no-verify",
|
|
158
|
+
"-m",
|
|
159
|
+
`chore: initial commit from GatoJS v${version}`,
|
|
160
|
+
])
|
|
161
|
+
: add;
|
|
162
|
+
if (result.code !== 0) {
|
|
163
|
+
context.deps.ui.warn(`Could not create the first commit (${tail(result) || `exit ${result.code}`}); configure git and commit by hand.`);
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
async function kitVersionOf(projectDir) {
|
|
169
|
+
const state = JSON.parse(await readFile(join(projectDir, ".wa/kit.json"), "utf8"));
|
|
170
|
+
return typeof state.kitVersion === "string" ? state.kitVersion : "unknown";
|
|
171
|
+
}
|
|
172
|
+
function profilesFor(answers) {
|
|
173
|
+
return answers.storage?.provider === "s3" && answers.storage.localMinio
|
|
174
|
+
? [S3_PROFILE]
|
|
175
|
+
: [];
|
|
176
|
+
}
|
|
177
|
+
export async function runWizard(deps, args, kitDir, projectDir) {
|
|
178
|
+
const context = { deps, projectDir };
|
|
179
|
+
deps.ui.intro("create-gato-app");
|
|
180
|
+
const answers = await collectAnswers({
|
|
181
|
+
args,
|
|
182
|
+
slug: basename(projectDir),
|
|
183
|
+
modules: await readKitModules(kitDir),
|
|
184
|
+
prompter: deps.prompter,
|
|
185
|
+
});
|
|
186
|
+
await assemble(context, args, kitDir, answers);
|
|
187
|
+
const envText = await writeWizardEnv(context, answers);
|
|
188
|
+
const version = await kitVersionOf(projectDir);
|
|
189
|
+
const profiles = profilesFor(answers);
|
|
190
|
+
const outcome = {
|
|
191
|
+
dir: displayDir(deps.cwd, projectDir),
|
|
192
|
+
git: args.git,
|
|
193
|
+
installed: false,
|
|
194
|
+
committed: false,
|
|
195
|
+
dockerUp: false,
|
|
196
|
+
profiles,
|
|
197
|
+
migrated: false,
|
|
198
|
+
adminCreated: false,
|
|
199
|
+
adminEmail: answers.adminEmail,
|
|
200
|
+
};
|
|
201
|
+
let failed = false;
|
|
202
|
+
if (answers.setup) {
|
|
203
|
+
outcome.dockerUp = await startDocker(context, envText, profiles);
|
|
204
|
+
failed = !outcome.dockerUp;
|
|
205
|
+
}
|
|
206
|
+
if (args.git) {
|
|
207
|
+
const init = await runQuiet(context, "git", ["init", "-q"]);
|
|
208
|
+
if (init.code !== 0) {
|
|
209
|
+
deps.ui.warn(`git init failed (${tail(init)}); the project has no repository.`);
|
|
210
|
+
outcome.git = false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (args.install) {
|
|
214
|
+
outcome.installed = await install(context);
|
|
215
|
+
failed ||= !outcome.installed;
|
|
216
|
+
}
|
|
217
|
+
if (outcome.installed && outcome.dockerUp) {
|
|
218
|
+
outcome.migrated = await migrate(context);
|
|
219
|
+
failed ||= !outcome.migrated;
|
|
220
|
+
}
|
|
221
|
+
if (outcome.migrated && answers.adminEmail !== null) {
|
|
222
|
+
outcome.adminCreated = await createAdmin(context, answers.adminEmail);
|
|
223
|
+
failed ||= !outcome.adminCreated;
|
|
224
|
+
}
|
|
225
|
+
if (outcome.git && outcome.installed) {
|
|
226
|
+
outcome.committed = await commit(context, version);
|
|
227
|
+
}
|
|
228
|
+
deps.ui.note("Next steps", nextSteps(outcome));
|
|
229
|
+
deps.ui.outro(failed
|
|
230
|
+
? `The project is in ${outcome.dir}, but some steps did not finish (see above).`
|
|
231
|
+
: `Done: ${answers.title} is ready in ${outcome.dir}.`);
|
|
232
|
+
return failed ? 1 : 0;
|
|
233
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-gato-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Create a GatoJS project (Next.js kit) with one command",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"test:smoke": "bash scripts/smoke-pack.sh"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"
|
|
51
|
+
"@clack/prompts": "^1.9.0",
|
|
52
|
+
"gato-cli": "0.3.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@eslint/js": "^9.39.5",
|