@slicemachine/init 0.1.1-dev-plugins.3 → 0.1.1-dev-plugins.4
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/SliceMachineInitProcess.cjs +111 -43
- package/dist/SliceMachineInitProcess.cjs.map +1 -1
- package/dist/SliceMachineInitProcess.d.ts +4 -0
- package/dist/SliceMachineInitProcess.js +112 -44
- package/dist/SliceMachineInitProcess.js.map +1 -1
- package/dist/__node_modules/@babel/code-frame/lib/index.cjs +1 -1
- package/dist/__node_modules/@babel/code-frame/lib/index.js +1 -1
- package/dist/__node_modules/@babel/helper-validator-identifier/lib/index.cjs +1 -1
- package/dist/__node_modules/@babel/helper-validator-identifier/lib/index.js +1 -1
- package/dist/__node_modules/@babel/highlight/lib/index.cjs +3 -3
- package/dist/__node_modules/@babel/highlight/lib/index.js +3 -3
- package/dist/__node_modules/@nodelib/fs.scandir/out/providers/async.cjs +1 -1
- package/dist/__node_modules/@nodelib/fs.scandir/out/providers/async.js +1 -1
- package/dist/__node_modules/@nodelib/fs.scandir/out/providers/sync.cjs +1 -1
- package/dist/__node_modules/@nodelib/fs.scandir/out/providers/sync.js +1 -1
- package/dist/__node_modules/@nodelib/fs.scandir/out/settings.cjs +1 -1
- package/dist/__node_modules/@nodelib/fs.scandir/out/settings.js +1 -1
- package/dist/__node_modules/@nodelib/fs.stat/out/index.cjs +1 -1
- package/dist/__node_modules/@nodelib/fs.stat/out/index.js +1 -1
- package/dist/__node_modules/@nodelib/fs.walk/out/index.cjs +1 -1
- package/dist/__node_modules/@nodelib/fs.walk/out/index.js +1 -1
- package/dist/__node_modules/camelcase-keys/index.cjs +1 -1
- package/dist/__node_modules/camelcase-keys/index.js +1 -1
- package/dist/__node_modules/cross-spawn/index.cjs +1 -1
- package/dist/__node_modules/cross-spawn/index.js +1 -1
- package/dist/__node_modules/cross-spawn/lib/util/resolveCommand.cjs +1 -1
- package/dist/__node_modules/cross-spawn/lib/util/resolveCommand.js +1 -1
- package/dist/__node_modules/dir-glob/index.cjs +2 -2
- package/dist/__node_modules/dir-glob/index.js +2 -2
- package/dist/__node_modules/fast-glob/out/index.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/index.js +1 -1
- package/dist/__node_modules/fast-glob/out/managers/tasks.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/managers/tasks.js +1 -1
- package/dist/__node_modules/fast-glob/out/providers/filters/deep.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/providers/filters/deep.js +1 -1
- package/dist/__node_modules/fast-glob/out/providers/filters/entry.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/providers/filters/entry.js +1 -1
- package/dist/__node_modules/fast-glob/out/providers/filters/error.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/providers/filters/error.js +1 -1
- package/dist/__node_modules/fast-glob/out/providers/matchers/matcher.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/providers/matchers/matcher.js +1 -1
- package/dist/__node_modules/fast-glob/out/providers/transformers/entry.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/providers/transformers/entry.js +1 -1
- package/dist/__node_modules/fast-glob/out/readers/async.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/readers/async.js +1 -1
- package/dist/__node_modules/fast-glob/out/readers/reader.cjs +2 -2
- package/dist/__node_modules/fast-glob/out/readers/reader.js +2 -2
- package/dist/__node_modules/fast-glob/out/readers/stream.cjs +2 -2
- package/dist/__node_modules/fast-glob/out/readers/stream.js +2 -2
- package/dist/__node_modules/fast-glob/out/readers/sync.cjs +2 -2
- package/dist/__node_modules/fast-glob/out/readers/sync.js +2 -2
- package/dist/__node_modules/fast-glob/out/utils/index.cjs +1 -1
- package/dist/__node_modules/fast-glob/out/utils/index.js +1 -1
- package/dist/__node_modules/globby/index.cjs +1 -1
- package/dist/__node_modules/globby/index.js +1 -1
- package/dist/__node_modules/js-tokens/index.cjs +1 -1
- package/dist/__node_modules/js-tokens/index.js +1 -1
- package/dist/__node_modules/map-obj/index.cjs +1 -1
- package/dist/__node_modules/map-obj/index.js +1 -1
- package/dist/__node_modules/meow/__node_modules/hosted-git-info/lib/index.cjs +1 -1
- package/dist/__node_modules/meow/__node_modules/hosted-git-info/lib/index.js +1 -1
- package/dist/__node_modules/meow/__node_modules/normalize-package-data/lib/fixer.cjs +1 -1
- package/dist/__node_modules/meow/__node_modules/normalize-package-data/lib/fixer.js +1 -1
- package/dist/__node_modules/meow/__node_modules/read-pkg/__node_modules/hosted-git-info/index.cjs +1 -1
- package/dist/__node_modules/meow/__node_modules/read-pkg/__node_modules/hosted-git-info/index.js +1 -1
- package/dist/__node_modules/meow/__node_modules/read-pkg/__node_modules/normalize-package-data/lib/fixer.cjs +1 -1
- package/dist/__node_modules/meow/__node_modules/read-pkg/__node_modules/normalize-package-data/lib/fixer.js +1 -1
- package/dist/__node_modules/micromatch/index.cjs +1 -1
- package/dist/__node_modules/micromatch/index.js +1 -1
- package/dist/__node_modules/path-key/index.cjs +1 -1
- package/dist/__node_modules/path-key/index.js +1 -1
- package/dist/__node_modules/path-type/index.cjs +1 -1
- package/dist/__node_modules/path-type/index.js +1 -1
- package/dist/__node_modules/picomatch/index.cjs +1 -1
- package/dist/__node_modules/picomatch/index.js +1 -1
- package/dist/_virtual/index13.cjs +2 -2
- package/dist/_virtual/index13.js +2 -2
- package/dist/_virtual/index14.cjs +10 -2
- package/dist/_virtual/index14.cjs.map +1 -1
- package/dist/_virtual/index14.js +11 -2
- package/dist/_virtual/index14.js.map +1 -1
- package/dist/_virtual/index15.cjs +2 -2
- package/dist/_virtual/index15.js +2 -2
- package/dist/_virtual/index16.cjs +2 -10
- package/dist/_virtual/index16.cjs.map +1 -1
- package/dist/_virtual/index16.js +2 -11
- package/dist/_virtual/index16.js.map +1 -1
- package/dist/_virtual/index17.cjs +2 -2
- package/dist/_virtual/index17.js +6 -6
- package/dist/_virtual/index18.cjs +2 -10
- package/dist/_virtual/index18.cjs.map +1 -1
- package/dist/_virtual/index18.js +2 -11
- package/dist/_virtual/index18.js.map +1 -1
- package/dist/_virtual/index19.cjs +2 -2
- package/dist/_virtual/index19.js +2 -2
- package/dist/_virtual/index20.cjs +10 -2
- package/dist/_virtual/index20.cjs.map +1 -1
- package/dist/_virtual/index20.js +11 -2
- package/dist/_virtual/index20.js.map +1 -1
- package/dist/_virtual/index3.cjs +2 -2
- package/dist/_virtual/index3.js +6 -6
- package/dist/_virtual/index4.cjs +2 -2
- package/dist/_virtual/index4.js +6 -6
- package/dist/_virtual/index5.cjs +10 -2
- package/dist/_virtual/index5.cjs.map +1 -1
- package/dist/_virtual/index5.js +11 -2
- package/dist/_virtual/index5.js.map +1 -1
- package/dist/_virtual/index6.cjs +10 -2
- package/dist/_virtual/index6.cjs.map +1 -1
- package/dist/_virtual/index6.js +11 -2
- package/dist/_virtual/index6.js.map +1 -1
- package/dist/_virtual/index7.cjs +2 -10
- package/dist/_virtual/index7.cjs.map +1 -1
- package/dist/_virtual/index7.js +2 -11
- package/dist/_virtual/index7.js.map +1 -1
- package/dist/_virtual/index8.cjs +2 -10
- package/dist/_virtual/index8.cjs.map +1 -1
- package/dist/_virtual/index8.js +2 -11
- package/dist/_virtual/index8.js.map +1 -1
- package/dist/constants.cjs +7 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +7 -0
- package/dist/constants.js.map +1 -0
- package/dist/lib/framework.cjs +7 -3
- package/dist/lib/framework.cjs.map +1 -1
- package/dist/lib/framework.d.ts +8 -0
- package/dist/lib/framework.js +7 -3
- package/dist/lib/framework.js.map +1 -1
- package/dist/lib/packageManager.cjs +11 -3
- package/dist/lib/packageManager.cjs.map +1 -1
- package/dist/lib/packageManager.d.ts +9 -1
- package/dist/lib/packageManager.js +12 -4
- package/dist/lib/packageManager.js.map +1 -1
- package/dist/lib/prompt.cjs +3 -2
- package/dist/lib/prompt.cjs.map +1 -1
- package/dist/lib/prompt.js +3 -2
- package/dist/lib/prompt.js.map +1 -1
- package/dist/packages/init/__node_modules/execa/index.cjs +1 -1
- package/dist/packages/init/__node_modules/execa/index.js +1 -1
- package/dist/packages/init/package.json.cjs +1 -1
- package/dist/packages/init/package.json.js +1 -1
- package/package.json +8 -3
- package/src/SliceMachineInitProcess.ts +176 -61
- package/src/constants.ts +3 -0
- package/src/lib/framework.ts +20 -7
- package/src/lib/packageManager.ts +20 -4
- package/src/lib/prompt.ts +2 -2
|
@@ -12,11 +12,12 @@ import logSymbols from "log-symbols";
|
|
|
12
12
|
import { globby } from './__node_modules/globby/index.js';
|
|
13
13
|
import { createSliceMachineManager } from "@slicemachine/manager";
|
|
14
14
|
import { detectFramework } from "./lib/framework.js";
|
|
15
|
-
import { installDependencies, detectPackageManager } from "./lib/packageManager.js";
|
|
15
|
+
import { getRunScriptCommand, getExecuteCommand, installDependencies, detectPackageManager } from "./lib/packageManager.js";
|
|
16
16
|
import { formatRepositoryDomain, validateRepositoryDomainAndAvailability, getErrorMessageForRepositoryDomainValidation, getRandomRepositoryDomain, validateRepositoryDomain } from "./lib/repositoryDomain.js";
|
|
17
17
|
import { listrRun, listr } from "./lib/listr.js";
|
|
18
18
|
import { prompt } from "./lib/prompt.js";
|
|
19
19
|
import { assertExists } from "./lib/assertExists.js";
|
|
20
|
+
import { START_SCRIPT_KEY, START_SCRIPT_VALUE } from "./constants.js";
|
|
20
21
|
const DEFAULT_OPTIONS = {
|
|
21
22
|
push: true,
|
|
22
23
|
pushSlices: true,
|
|
@@ -47,6 +48,7 @@ class SliceMachineInitProcess {
|
|
|
47
48
|
this.context = {};
|
|
48
49
|
}
|
|
49
50
|
async run() {
|
|
51
|
+
var _a;
|
|
50
52
|
console.log(`
|
|
51
53
|
${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} Init command started
|
|
52
54
|
`);
|
|
@@ -72,6 +74,7 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
|
|
|
72
74
|
await this.finishCoreDependenciesInstallation();
|
|
73
75
|
await this.upsertSliceMachineConfigurationAndStartPluginRunner();
|
|
74
76
|
await this.pushDataToPrismic();
|
|
77
|
+
await this.initializeProject();
|
|
75
78
|
await this.initializePlugins();
|
|
76
79
|
} catch (error) {
|
|
77
80
|
await this.trackError(error);
|
|
@@ -85,6 +88,26 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
|
|
|
85
88
|
});
|
|
86
89
|
console.log(`
|
|
87
90
|
${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} Init command successful!`);
|
|
91
|
+
try {
|
|
92
|
+
console.log(`
|
|
93
|
+
YOUR REPOSITORY
|
|
94
|
+
Dashboard ${chalk.cyan(`https://${this.context.repository.domain}.prismic.io`)}
|
|
95
|
+
API ${chalk.cyan(`https://${this.context.repository.domain}.cdn.prismic.io/api/v2`)}
|
|
96
|
+
|
|
97
|
+
RESOURCES
|
|
98
|
+
Documentation ${chalk.cyan(this.context.framework.prismicDocumentation)}
|
|
99
|
+
Getting help ${chalk.cyan("https://community.prismic.io")}
|
|
100
|
+
|
|
101
|
+
GETTING STARTED
|
|
102
|
+
Start Slice Machine ${chalk.cyan(((_a = this.context.projectInitialization) == null ? void 0 : _a.patchedScript) ? await getRunScriptCommand({
|
|
103
|
+
agent: this.context.packageManager || "npm",
|
|
104
|
+
script: "slicemachine"
|
|
105
|
+
}) : await getExecuteCommand({
|
|
106
|
+
agent: this.context.packageManager || "npm",
|
|
107
|
+
script: "start-slicemachine"
|
|
108
|
+
}))}`);
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
88
111
|
}
|
|
89
112
|
detectEnvironment() {
|
|
90
113
|
return listrRun([
|
|
@@ -101,7 +124,15 @@ ${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} I
|
|
|
101
124
|
{
|
|
102
125
|
title: "Detecting package manager...",
|
|
103
126
|
task: async (_2, task) => {
|
|
104
|
-
|
|
127
|
+
try {
|
|
128
|
+
this.context.packageManager = await detectPackageManager(this.options.cwd);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error instanceof Error && (error.message.match(/failed to detect/i) || error.message.match(/command failed/i))) {
|
|
131
|
+
this.context.packageManager = "npm";
|
|
132
|
+
} else {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
105
136
|
task.title = `Detected package manager ${chalk.cyan(this.context.packageManager)}`;
|
|
106
137
|
assertExists(this.context.framework, "Project framework must be available through context to proceed");
|
|
107
138
|
parentTask.title = `Detected framework ${chalk.cyan(this.context.framework.name)} and package manager ${chalk.cyan(this.context.packageManager)}`;
|
|
@@ -156,10 +187,12 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
156
187
|
if (!isLoggedIn) {
|
|
157
188
|
parentTask.output = "Press any key to open the browser to login...";
|
|
158
189
|
await new Promise((resolve) => {
|
|
159
|
-
|
|
160
|
-
process.stdin.
|
|
190
|
+
var _a, _b;
|
|
191
|
+
const initialRawMode = !!process.stdin.isRaw;
|
|
192
|
+
(_b = (_a = process.stdin).setRawMode) == null ? void 0 : _b.call(_a, true);
|
|
161
193
|
process.stdin.once("data", (data) => {
|
|
162
|
-
|
|
194
|
+
var _a2, _b2;
|
|
195
|
+
(_b2 = (_a2 = process.stdin).setRawMode) == null ? void 0 : _b2.call(_a2, initialRawMode);
|
|
163
196
|
process.stdin.pause();
|
|
164
197
|
resolve(data.toString("utf-8"));
|
|
165
198
|
});
|
|
@@ -169,9 +202,7 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
169
202
|
await this.manager.user.nodeLoginSession({
|
|
170
203
|
port,
|
|
171
204
|
onListenCallback() {
|
|
172
|
-
open(url)
|
|
173
|
-
throw error;
|
|
174
|
-
});
|
|
205
|
+
open(url);
|
|
175
206
|
}
|
|
176
207
|
});
|
|
177
208
|
}
|
|
@@ -214,13 +245,13 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
214
245
|
task: async (_, task) => {
|
|
215
246
|
assertExists(this.context.userRepositories, "User repositories must be available through context to run `useRepositoryFlag`");
|
|
216
247
|
assertExists(this.options.repository, "Flag `repository` must be set to run `useRepositoryFlag`");
|
|
217
|
-
const
|
|
248
|
+
const domain = formatRepositoryDomain(this.options.repository);
|
|
249
|
+
const maybeRepository = this.context.userRepositories.find((repository) => repository.domain === domain);
|
|
218
250
|
if (maybeRepository) {
|
|
219
251
|
if (!this.manager.prismicRepository.hasWriteAccess(maybeRepository)) {
|
|
220
252
|
throw new Error(`Cannot run init command with repository ${chalk.cyan(maybeRepository.domain)}: you are not a developer or admin of this repository`);
|
|
221
253
|
}
|
|
222
254
|
} else {
|
|
223
|
-
const domain = formatRepositoryDomain(this.options.repository);
|
|
224
255
|
const validation = await validateRepositoryDomainAndAvailability({
|
|
225
256
|
domain,
|
|
226
257
|
existsFn: (domain2) => this.manager.prismicRepository.checkExists({ domain: domain2 })
|
|
@@ -233,9 +264,9 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
233
264
|
throw new Error(errorMessage);
|
|
234
265
|
}
|
|
235
266
|
}
|
|
236
|
-
task.title = `Selected repository ${chalk.cyan(
|
|
267
|
+
task.title = `Selected repository ${chalk.cyan(domain)} (flag ${chalk.cyan("repository")} used)`;
|
|
237
268
|
this.context.repository = {
|
|
238
|
-
domain
|
|
269
|
+
domain,
|
|
239
270
|
exists: !!maybeRepository
|
|
240
271
|
};
|
|
241
272
|
}
|
|
@@ -285,6 +316,7 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
285
316
|
}
|
|
286
317
|
}
|
|
287
318
|
async selectNewRepository() {
|
|
319
|
+
var _a, _b, _c, _d;
|
|
288
320
|
let suggestedName = "";
|
|
289
321
|
const trySuggestName = async (name) => {
|
|
290
322
|
if (name) {
|
|
@@ -312,12 +344,11 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
312
344
|
}
|
|
313
345
|
}
|
|
314
346
|
if (!suggestedName) {
|
|
315
|
-
|
|
316
|
-
while (await this.manager.prismicRepository.checkExists({
|
|
317
|
-
domain: suggestedName
|
|
318
|
-
})) {
|
|
347
|
+
do {
|
|
319
348
|
suggestedName = getRandomRepositoryDomain();
|
|
320
|
-
}
|
|
349
|
+
} while (await this.manager.prismicRepository.checkExists({
|
|
350
|
+
domain: suggestedName
|
|
351
|
+
}));
|
|
321
352
|
}
|
|
322
353
|
const { domain } = await prompt({
|
|
323
354
|
type: "text",
|
|
@@ -329,21 +360,23 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
329
360
|
const rawDomain = this.value || this.initial || "";
|
|
330
361
|
const domain2 = formatRepositoryDomain(rawDomain);
|
|
331
362
|
const validation = validateRepositoryDomain({ domain: domain2 });
|
|
363
|
+
const minRule = validation.LessThan4 ? chalk.red(`1. Name must be ${chalk.bold("4 characters long or more")}`) : `1. Name must be ${chalk.cyan("4 characters long or more")}`;
|
|
364
|
+
const maxRule = validation.MoreThan30 ? chalk.red(`1. Name must be ${chalk.bold("30 characters long or less")}`) : `1. Name must be ${chalk.cyan("30 characters long or less")}`;
|
|
332
365
|
this.msg = chalk.reset(`
|
|
333
366
|
Choose a name for your Prismic repository
|
|
334
367
|
|
|
335
368
|
NAMING RULES
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
369
|
+
${minRule}
|
|
370
|
+
${maxRule}
|
|
371
|
+
3. Name will be ${chalk.cyan("kebab-cased")} automatically
|
|
339
372
|
|
|
340
373
|
CONSIDERATIONS
|
|
341
|
-
|
|
342
|
-
|
|
374
|
+
1. Once picked, your repository name ${chalk.cyan("cannot be changed")}
|
|
375
|
+
2. A ${chalk.cyan("display name")} for the repository can be configured later on
|
|
343
376
|
|
|
344
377
|
PREVIEW
|
|
345
|
-
|
|
346
|
-
|
|
378
|
+
Dashboard ${chalk.cyan(`https://${domain2}.prismic.io`)}
|
|
379
|
+
API ${chalk.cyan(`https://${domain2}.cdn.prismic.io/api/v2`)}
|
|
347
380
|
|
|
348
381
|
${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
349
382
|
},
|
|
@@ -363,8 +396,8 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
363
396
|
return formatRepositoryDomain(value);
|
|
364
397
|
}
|
|
365
398
|
});
|
|
366
|
-
process.stdout.moveCursor(0, -16);
|
|
367
|
-
process.stdout.clearScreenDown();
|
|
399
|
+
(_b = (_a = process.stdout).moveCursor) == null ? void 0 : _b.call(_a, 0, -16);
|
|
400
|
+
(_d = (_c = process.stdout).clearScreenDown) == null ? void 0 : _d.call(_c);
|
|
368
401
|
this.context.repository = {
|
|
369
402
|
domain,
|
|
370
403
|
exists: false
|
|
@@ -400,18 +433,17 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
400
433
|
task.output = data.toString();
|
|
401
434
|
}
|
|
402
435
|
};
|
|
403
|
-
(
|
|
436
|
+
if (process.stdout.isTTY || process.env.NODE_ENV === "test") {
|
|
437
|
+
(_a = this.context.installProcess.stdout) == null ? void 0 : _a.on("data", updateOutput);
|
|
438
|
+
}
|
|
404
439
|
(_b = this.context.installProcess.stderr) == null ? void 0 : _b.on("data", updateOutput);
|
|
405
440
|
try {
|
|
406
441
|
await this.context.installProcess;
|
|
407
442
|
} catch (error) {
|
|
408
|
-
await new Promise(() =>
|
|
409
|
-
|
|
410
|
-
throw error;
|
|
411
|
-
}, 5e3);
|
|
412
|
-
});
|
|
443
|
+
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
444
|
+
throw error;
|
|
413
445
|
}
|
|
414
|
-
task.title = `
|
|
446
|
+
task.title = `Installed core dependencies with ${chalk.cyan(this.context.packageManager)}`;
|
|
415
447
|
}
|
|
416
448
|
}
|
|
417
449
|
]);
|
|
@@ -435,7 +467,8 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
435
467
|
await this.manager.project.writeSliceMachineConfig({
|
|
436
468
|
config: {
|
|
437
469
|
...config,
|
|
438
|
-
repositoryName: this.context.repository.domain
|
|
470
|
+
repositoryName: this.context.repository.domain,
|
|
471
|
+
adapter: this.context.framework.adapterName
|
|
439
472
|
}
|
|
440
473
|
});
|
|
441
474
|
parentTask.title = "Updated Slice Machine configuration";
|
|
@@ -568,7 +601,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
568
601
|
});
|
|
569
602
|
if (documentsGlob.length === 0) {
|
|
570
603
|
parentTask.title = "Pushed data to Prismic";
|
|
571
|
-
task.skip("No
|
|
604
|
+
task.skip("No document to push");
|
|
572
605
|
return;
|
|
573
606
|
}
|
|
574
607
|
const documents = await Promise.all(documentsGlob.map(async (document) => {
|
|
@@ -605,7 +638,44 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
605
638
|
}
|
|
606
639
|
]);
|
|
607
640
|
}
|
|
608
|
-
|
|
641
|
+
initializeProject() {
|
|
642
|
+
return listrRun([
|
|
643
|
+
{
|
|
644
|
+
title: "Initializing project...",
|
|
645
|
+
task: async (_, parentTask) => // We return another Listr instance in the event we have additional task to perform to initialize the project
|
|
646
|
+
listr([
|
|
647
|
+
{
|
|
648
|
+
title: `Patching ${chalk.cyan("package.json")} scripts...`,
|
|
649
|
+
task: async (_2, task) => {
|
|
650
|
+
var _a, _b;
|
|
651
|
+
const pkgPath = path.join(this.manager.cwd, "package.json");
|
|
652
|
+
try {
|
|
653
|
+
const pkgRaw = await fs.readFile(pkgPath, "utf-8");
|
|
654
|
+
const pkg = JSON.parse(pkgRaw);
|
|
655
|
+
pkg.scripts || (pkg.scripts = {});
|
|
656
|
+
if (!pkg.scripts[START_SCRIPT_KEY]) {
|
|
657
|
+
pkg.scripts[START_SCRIPT_KEY] = START_SCRIPT_VALUE;
|
|
658
|
+
const firstIndent = pkgRaw.split("\n").find((line) => line.match(/^(?:( )+|\t+)/));
|
|
659
|
+
const indent = (_a = firstIndent == null ? void 0 : firstIndent.match(/^(?:( )+|\t+)/)) == null ? void 0 : _a[0];
|
|
660
|
+
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, indent && indent !== " " ? indent : " "));
|
|
661
|
+
} else if (!pkg.scripts["slicemachine"].startsWith(START_SCRIPT_VALUE)) {
|
|
662
|
+
throw new Error("Script already exists");
|
|
663
|
+
}
|
|
664
|
+
} catch (error) {
|
|
665
|
+
task.title = `Could not patch ${chalk.cyan("package.json")} scripts (warning)`;
|
|
666
|
+
parentTask.title = `Initialized project (could not patch ${chalk.cyan("package.json")} scripts)`;
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
(_b = this.context).projectInitialization || (_b.projectInitialization = {});
|
|
670
|
+
this.context.projectInitialization.patchedScript = true;
|
|
671
|
+
task.title = `Patched ${chalk.cyan("package.json")} scripts`;
|
|
672
|
+
parentTask.title = `Initialized project (patched ${chalk.cyan("package.json")} scripts)`;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
])
|
|
676
|
+
}
|
|
677
|
+
]);
|
|
678
|
+
}
|
|
609
679
|
initializePlugins() {
|
|
610
680
|
return listrRun([
|
|
611
681
|
{
|
|
@@ -628,23 +698,21 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
628
698
|
...args,
|
|
629
699
|
agent: this.context.packageManager
|
|
630
700
|
});
|
|
631
|
-
(
|
|
701
|
+
if (process.stdout.isTTY || process.env.NODE_ENV === "test") {
|
|
702
|
+
(_a = execaProcess.stdout) == null ? void 0 : _a.on("data", updateOutput);
|
|
703
|
+
}
|
|
632
704
|
(_b = execaProcess.stderr) == null ? void 0 : _b.on("data", updateOutput);
|
|
633
705
|
await execaProcess;
|
|
634
706
|
} catch (error) {
|
|
635
707
|
if (error instanceof Error && "shortMessage" in error && "stderr" in error) {
|
|
636
|
-
|
|
637
|
-
console.error(`
|
|
708
|
+
throw new Error(`
|
|
638
709
|
|
|
639
710
|
${error.shortMessage}
|
|
640
711
|
${error.stderr}
|
|
641
712
|
|
|
642
|
-
${logSymbols.error} Plugins dependency installation failed
|
|
643
|
-
} else {
|
|
644
|
-
await this.trackError(error);
|
|
645
|
-
console.error(error);
|
|
713
|
+
${logSymbols.error} Plugins dependency installation failed`, { cause: error });
|
|
646
714
|
}
|
|
647
|
-
|
|
715
|
+
throw error;
|
|
648
716
|
}
|
|
649
717
|
}
|
|
650
718
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceMachineInitProcess.js","sources":["../../src/SliceMachineInitProcess.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport chalk from \"chalk\";\nimport { ExecaChildProcess } from \"execa\";\nimport open from \"open\";\nimport logSymbols from \"log-symbols\";\nimport { globby } from \"globby\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n} from \"@slicemachine/manager\";\n\nimport { detectFramework, Framework } from \"./lib/framework\";\nimport {\n\tinstallDependencies,\n\tdetectPackageManager,\n\tPackageManagerAgent,\n} from \"./lib/packageManager\";\nimport {\n\tgetRandomRepositoryDomain,\n\tformatRepositoryDomain,\n\tvalidateRepositoryDomain,\n\tvalidateRepositoryDomainAndAvailability,\n\tgetErrorMessageForRepositoryDomainValidation,\n} from \"./lib/repositoryDomain\";\nimport { listr, listrRun } from \"./lib/listr\";\nimport { prompt } from \"./lib/prompt\";\nimport { assertExists } from \"./lib/assertExists\";\n\nexport type SliceMachineInitProcessOptions = {\n\trepository?: string;\n\tpush?: boolean;\n\tpushSlices?: boolean;\n\tpushCustomTypes?: boolean;\n\tpushDocuments?: boolean;\n\tcwd?: string;\n} & Record<string, unknown>;\n\nconst DEFAULT_OPTIONS: SliceMachineInitProcessOptions = {\n\tpush: true,\n\tpushSlices: true,\n\tpushCustomTypes: true,\n\tpushDocuments: true,\n};\n\nexport const createSliceMachineInitProcess = (\n\toptions?: SliceMachineInitProcessOptions,\n): SliceMachineInitProcess => {\n\treturn new SliceMachineInitProcess(options);\n};\n\ntype SliceMachineInitProcessContext = {\n\tframework?: Framework;\n\tpackageManager?: PackageManagerAgent;\n\tinstallProcess?: ExecaChildProcess;\n\tuserProfile?: PrismicUserProfile;\n\tuserRepositories?: PrismicRepository[];\n\trepository?: {\n\t\tdomain: string;\n\t\texists: boolean;\n\t};\n};\n\nexport class SliceMachineInitProcess {\n\tprotected options: SliceMachineInitProcessOptions;\n\tprotected manager: SliceMachineManager;\n\n\tprotected context: SliceMachineInitProcessContext;\n\n\tconstructor(options?: SliceMachineInitProcessOptions) {\n\t\tthis.options = { ...DEFAULT_OPTIONS, ...options };\n\t\tthis.manager = createSliceMachineManager({ cwd: options?.cwd });\n\n\t\tthis.context = {};\n\t}\n\n\tasync run(): Promise<void> {\n\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(\n\t\t\t`\\n${chalk.bgGray(` ${chalk.bold.white(\"Slice Machine\")} `)} ${chalk.dim(\n\t\t\t\t\"→\",\n\t\t\t)} Init command started\\n`,\n\t\t);\n\n\t\tawait this.manager.telemetry.initTelemetry();\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:start\",\n\t\t\trepository: this.options.repository,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.detectEnvironment();\n\n\t\t\tassertExists(\n\t\t\t\tthis.context.framework,\n\t\t\t\t\"Project framework must be available through context to proceed\",\n\t\t\t);\n\n\t\t\tawait this.beginCoreDependenciesInstallation();\n\t\t\tawait this.loginAndFetchUserData();\n\n\t\t\tif (this.options.repository) {\n\t\t\t\tawait this.useRepositoryFlag();\n\t\t\t} else {\n\t\t\t\tawait this.selectRepository();\n\t\t\t}\n\n\t\t\tassertExists(\n\t\t\t\tthis.context.repository,\n\t\t\t\t\"Repository selection must be available through context to proceed\",\n\t\t\t);\n\n\t\t\tif (!this.context.repository.exists) {\n\t\t\t\tawait this.createNewRepository();\n\t\t\t}\n\n\t\t\tawait this.finishCoreDependenciesInstallation();\n\t\t\tawait this.upsertSliceMachineConfigurationAndStartPluginRunner();\n\t\t\tawait this.pushDataToPrismic();\n\t\t\tawait this.initializePlugins();\n\t\t} catch (error) {\n\t\t\tawait this.trackError(error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework.prismicName,\n\t\t\trepository: this.context.repository.domain,\n\t\t\tsuccess: true,\n\t\t});\n\n\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(\n\t\t\t`\\n${chalk.bgGreen(` ${chalk.bold.white(\"Slice Machine\")} `)} ${chalk.dim(\n\t\t\t\t\"→\",\n\t\t\t)} Init command successful!`,\n\t\t);\n\t}\n\n\tprotected trackError = (error: unknown): Promise<void> => {\n\t\t// Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace\n\t\tconst safeError = (\n\t\t\terror instanceof Error ? error.message : `${error}`\n\t\t).slice(0, 512);\n\n\t\treturn this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework?.prismicName ?? \"unknown\",\n\t\t\trepository: this.context.repository?.domain,\n\t\t\tsuccess: false,\n\t\t\terror: safeError,\n\t\t});\n\t};\n\n\tprotected detectEnvironment(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Detecting environment...\",\n\t\t\t\ttask: (_, parentTask) =>\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Detecting framework...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.framework = await detectFramework(\n\t\t\t\t\t\t\t\t\tthis.manager.cwd,\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttask.title = `Detected framework ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.framework.name,\n\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Detecting package manager...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.packageManager = await detectPackageManager();\n\n\t\t\t\t\t\t\t\ttask.title = `Detected package manager ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\t\t)}`;\n\n\t\t\t\t\t\t\t\tassertExists(\n\t\t\t\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\t\t\t\"Project framework must be available through context to proceed\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tparentTask.title = `Detected framework ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.framework.name,\n\t\t\t\t\t\t\t\t)} and package manager ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected beginCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Beginning core dependencies installation...\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\"Project package manager must be available through context to run `beginCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `beginCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst { execaProcess } = await installDependencies({\n\t\t\t\t\t\tagent: this.context.packageManager,\n\t\t\t\t\t\tdependencies: this.context.framework.devDependencies,\n\t\t\t\t\t\tdev: true,\n\t\t\t\t\t});\n\n\t\t\t\t\t// Fail hard if process fails\n\t\t\t\t\texecaProcess.catch(async (error) => {\n\t\t\t\t\t\tconst [_, ...argv1n] = process.argv;\n\t\t\t\t\t\t// Command the user used\n\t\t\t\t\t\tlet tryAgainCommand = [process.argv0, ...argv1n].join(\" \");\n\n\t\t\t\t\t\t// If the `repository` option wasn't used AND the repository was selected/created\n\t\t\t\t\t\tif (!this.options.repository && this.context.repository) {\n\t\t\t\t\t\t\ttryAgainCommand = `${tryAgainCommand} --repository=${this.context.repository.domain}`;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait this.trackError(error.shortMessage);\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${\n\t\t\t\t\t\t\t\tlogSymbols.error\n\t\t\t\t\t\t\t} Dependency installation failed, try again with:\\n\\n ${chalk.gray(\n\t\t\t\t\t\t\t\t\"$\",\n\t\t\t\t\t\t\t)} ${chalk.cyan(tryAgainCommand)}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.installProcess = execaProcess;\n\n\t\t\t\t\ttask.title = `Began core dependencies installation with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)} ... (running in background)`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected loginAndFetchUserData(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Logging in to Prismic...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tparentTask.output = \"Validating session...\";\n\t\t\t\t\tconst isLoggedIn = await this.manager.user.checkIsLoggedIn();\n\n\t\t\t\t\tif (!isLoggedIn) {\n\t\t\t\t\t\tparentTask.output = \"Press any key to open the browser to login...\";\n\t\t\t\t\t\tawait new Promise((resolve) => {\n\t\t\t\t\t\t\tconst initialRawMode = process.stdin.isRaw;\n\t\t\t\t\t\t\tprocess.stdin.setRawMode(true);\n\t\t\t\t\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\t\t\t\t\tprocess.stdin.setRawMode(initialRawMode);\n\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\t\t\t\t\tawait this.manager.user.nodeLoginSession({\n\t\t\t\t\t\t\tport,\n\t\t\t\t\t\t\tonListenCallback() {\n\t\t\t\t\t\t\t\topen(url).catch((error) => {\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tparentTask.output = \"\";\n\t\t\t\t\tparentTask.title = `Logged in`;\n\n\t\t\t\t\treturn listr(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user profile...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\tthis.context.userProfile =\n\t\t\t\t\t\t\t\t\t\tawait this.manager.user.getProfile();\n\n\t\t\t\t\t\t\t\t\tawait this.manager.telemetry.identify({\n\t\t\t\t\t\t\t\t\t\tuserID: this.context.userProfile.shortId,\n\t\t\t\t\t\t\t\t\t\tintercomHash: this.context.userProfile.intercomHash,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tawait this.manager.telemetry.track({\n\t\t\t\t\t\t\t\t\t\tevent: \"command:init:identify\",\n\t\t\t\t\t\t\t\t\t\trepository: this.options.repository,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\tparentTask.title = `Logged in as ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\tthis.context.userProfile?.email,\n\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t\ttask.title = \"Fetched user profile\";\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user repositories...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\tthis.context.userRepositories =\n\t\t\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.readAll();\n\n\t\t\t\t\t\t\t\t\ttask.title = \"Fetched user repositories\";\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\t{ concurrent: true },\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected useRepositoryFlag(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Flag ${chalk.cyan(\"repository\")} used, validating input...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.userRepositories,\n\t\t\t\t\t\t\"User repositories must be available through context to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.options.repository,\n\t\t\t\t\t\t\"Flag `repository` must be set to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst maybeRepository = this.context.userRepositories.find(\n\t\t\t\t\t\t(repository) => repository.domain === this.options.repository,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (maybeRepository) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!this.manager.prismicRepository.hasWriteAccess(maybeRepository)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Cannot run init command with repository ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tmaybeRepository.domain,\n\t\t\t\t\t\t\t\t)}: you are not a developer or admin of this repository`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst domain = formatRepositoryDomain(this.options.repository);\n\t\t\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\t\t\tdomain,\n\t\t\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\t\t\tvalidation,\n\t\t\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (errorMessage) {\n\t\t\t\t\t\t\tthrow new Error(errorMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Selected repository ${chalk.cyan(\n\t\t\t\t\t\tthis.options.repository,\n\t\t\t\t\t)} (flag ${chalk.cyan(\"repository\")} used)`;\n\n\t\t\t\t\tthis.context.repository = {\n\t\t\t\t\t\tdomain: this.options.repository,\n\t\t\t\t\t\texists: !!maybeRepository,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected async selectRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to run `selectRepository`\",\n\t\t);\n\n\t\tif (this.context.userRepositories.length) {\n\t\t\tawait this.trySelectExistingRepository();\n\t\t}\n\n\t\tif (!this.context.repository) {\n\t\t\tawait this.selectNewRepository();\n\t\t}\n\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to proceed\",\n\t\t);\n\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(\n\t\t\t`${logSymbols.success} Selected repository ${chalk.cyan(\n\t\t\t\tthis.context.repository.domain,\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tprotected async trySelectExistingRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to run `trySelectExistingRepository`\",\n\t\t);\n\n\t\tconst { maybeDomain } = await prompt<string, \"maybeDomain\">({\n\t\t\ttype: \"select\",\n\t\t\tname: \"maybeDomain\",\n\t\t\tmessage: \"Pick a repository to connect to or choose to create a new one\",\n\t\t\twarn: \"You are not a developer or admin of this repository\",\n\t\t\tchoices: [\n\t\t\t\t{\n\t\t\t\t\ttitle: \"CREATE NEW\",\n\t\t\t\t\tdescription: \"Create a new Prismic repository\\n\",\n\t\t\t\t\tvalue: \"\",\n\t\t\t\t},\n\t\t\t\t...this.context.userRepositories\n\t\t\t\t\t.map((repository) => {\n\t\t\t\t\t\tconst hasWriteAccess =\n\t\t\t\t\t\t\tthis.manager.prismicRepository.hasWriteAccess(repository);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: `${repository.domain}${\n\t\t\t\t\t\t\t\thasWriteAccess ? \"\" : \" (Unauthorized)\"\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\tdescription: `Connect to ${chalk.cyan(repository.domain)}`,\n\t\t\t\t\t\t\tvalue: repository.domain,\n\t\t\t\t\t\t\tdisabled: !hasWriteAccess,\n\t\t\t\t\t\t};\n\t\t\t\t\t})\n\t\t\t\t\t.sort((a, b) => (a.value > b.value ? 1 : -1)),\n\t\t\t],\n\t\t});\n\n\t\tif (maybeDomain) {\n\t\t\tthis.context.repository = {\n\t\t\t\tdomain: maybeDomain,\n\t\t\t\texists: true,\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected async selectNewRepository(): Promise<void> {\n\t\tlet suggestedName = \"\";\n\n\t\t// TODO: Improve concurrency\n\t\tconst trySuggestName = async (name: string): Promise<string | void> => {\n\t\t\tif (name) {\n\t\t\t\tconst formattedName = formatRepositoryDomain(name);\n\n\t\t\t\tif (\n\t\t\t\t\t!validateRepositoryDomain({ domain: formattedName }).hasErrors &&\n\t\t\t\t\t!(await this.manager.prismicRepository.checkExists({\n\t\t\t\t\t\tdomain: formattedName,\n\t\t\t\t\t}))\n\t\t\t\t) {\n\t\t\t\t\treturn formattedName;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// 1. Try to suggest name after package name\n\t\ttry {\n\t\t\tconst pkgJSONPath = path.join(this.manager.cwd, \"package.json\");\n\t\t\tconst pkg = JSON.parse(await fs.readFile(pkgJSONPath, \"utf-8\"));\n\n\t\t\tconst maybeSuggestion = await trySuggestName(pkg.name);\n\t\t\tif (maybeSuggestion) {\n\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Noop\n\t\t}\n\n\t\t// 2. Try to suggest name after directory name\n\t\tif (!suggestedName) {\n\t\t\tconst maybeSuggestion = await trySuggestName(\n\t\t\t\tpath.basename(this.manager.cwd),\n\t\t\t);\n\t\t\tif (maybeSuggestion) {\n\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t}\n\t\t}\n\n\t\t// 3. Use random name\n\t\tif (!suggestedName) {\n\t\t\tsuggestedName = getRandomRepositoryDomain();\n\n\t\t\twhile (\n\t\t\t\tawait this.manager.prismicRepository.checkExists({\n\t\t\t\t\tdomain: suggestedName,\n\t\t\t\t})\n\t\t\t) {\n\t\t\t\tsuggestedName = getRandomRepositoryDomain();\n\t\t\t}\n\t\t}\n\n\t\tconst { domain } = await prompt<string, \"domain\">({\n\t\t\ttype: \"text\",\n\t\t\tname: \"domain\",\n\t\t\t// Overriden by the `onRender` function, just used as a fallback\n\t\t\tmessage: \"Choose a name for your Prismic repository\",\n\t\t\tinitial: suggestedName,\n\t\t\tonRender() {\n\t\t\t\tconst rawDomain = this.value || this.initial || \"\";\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = validateRepositoryDomain({ domain });\n\n\t\t\t\tthis.msg = chalk.reset(\n\t\t\t\t\t`\nChoose a name for your Prismic repository\n\n NAMING RULES\n${chalk[validation.LessThan4 ? \"red\" : \"gray\"](\n\t` 1. Name must be ${chalk[validation.LessThan4 ? \"bold\" : \"cyan\"](\n\t\t\"4 characters long or more\",\n\t)}`,\n)}\n${chalk[validation.MoreThan30 ? \"red\" : \"gray\"](\n\t` 2. Name must be ${chalk[validation.MoreThan30 ? \"bold\" : \"cyan\"](\n\t\t\"30 characters long or less\",\n\t)}`,\n)}\n${chalk.gray(` 3. Name will be ${chalk.cyan(\"kebab-cased\")} automatically`)}\n\n CONSIDERATIONS\n${chalk.gray(\n\t` 1. Once picked, your repository name ${chalk.cyan(\"cannot be changed\")}`,\n)}\n${chalk.gray(\n\t` 2. A ${chalk.cyan(\n\t\t\"display name\",\n\t)} for the repository can be configured later on`,\n)}\n\n PREVIEW\n${chalk.gray(` Dashboard ${chalk.cyan(`https://${domain}.prismic.io`)}`)}\n${chalk.gray(\n\t` API ${chalk.cyan(`https://${domain}.cdn.prismic.io/api/v2`)}`,\n)}\n\n${chalk.cyan(\"?\")} Your Prismic repository name`.replace(\"\\n\", \"\"),\n\t\t\t\t);\n\t\t\t},\n\t\t\tvalidate: async (rawDomain: string) => {\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\tdomain,\n\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t});\n\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\tvalidation,\n\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t});\n\n\t\t\t\treturn errorMessage || true;\n\t\t\t},\n\t\t\tformat: (value) => {\n\t\t\t\treturn formatRepositoryDomain(value);\n\t\t\t},\n\t\t});\n\n\t\t// Clear extra lines\n\t\tprocess.stdout.moveCursor(0, -16);\n\t\tprocess.stdout.clearScreenDown();\n\n\t\tthis.context.repository = {\n\t\t\tdomain,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tprotected createNewRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t);\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Creating new repository ${chalk.cyan(\n\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\tframework: this.context.framework.prismicName,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.title = `Created new repository ${chalk.cyan(\n\t\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected finishCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Finishing core dependencies installation with ${chalk.cyan(\n\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.installProcess,\n\t\t\t\t\t\t\"Initial dependencies installation process must be available through context to run `finishCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst updateOutput = (data: Buffer | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\t// TODO: Assert types\n\t\t\t\t\tthis.context.installProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\tthis.context.installProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.context.installProcess;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Error catching happens when then process is started ealier so\n\t\t\t\t\t\t * that all install errors, earlier and presents, can be catched.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * Here, we force the task to wait so that it is neither marked as\n\t\t\t\t\t\t * done or has the opportunity to handle the error itself\n\t\t\t\t\t\t */\n\t\t\t\t\t\tawait new Promise(() => {\n\t\t\t\t\t\t\t// If for whatever reason the process is not exited by now, we still throw the error\n\t\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t}, 5000);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Core dependencies installed with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Resolving Slice Machine configuration...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tlet sliceMachineConfigExists = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.manager.project.getSliceMachineConfigPath();\n\t\t\t\t\t\tsliceMachineConfigExists = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// noop, config does not exists, we'll create it\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sliceMachineConfigExists) {\n\t\t\t\t\t\tparentTask.title = \"Updating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst config = await this.manager.project.getSliceMachineConfig();\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tparentTask.title = \"Updated Slice Machine configuration\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentTask.title = \"Creating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst sliceMachineConfigPath =\n\t\t\t\t\t\t\tawait this.manager.project.suggestSliceMachineConfigPath();\n\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t// TODO: Update _latest to a real value or make it optional\n\t\t\t\t\t\t\t\t_latest: \"legacy\",\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t\tlibraries: [\"./slices\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpath: sliceMachineConfigPath,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.title = \"Created Slice Machine configuration\";\n\t\t\t\t\t}\n\n\t\t\t\t\treturn listr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Starting plugin runner...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tawait this.manager.plugins.initPlugins();\n\t\t\t\t\t\t\t\ttask.title = \"Started plugin runner\";\n\t\t\t\t\t\t\t\tparentTask.title = `${parentTask.title} and started plugin runner`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]);\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected pushDataToPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Pushing data to Prismic...\",\n\t\t\t\ttask: (_, parentTask) =>\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing slices...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushSlices) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-slices used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst { libraries, errors } =\n\t\t\t\t\t\t\t\t\tawait this.manager.slices.readAllSliceLibraries();\n\n\t\t\t\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\t\t\t\t// TODO: Provide better error message.\n\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t`Failed to read slice libraries: ${errors.join(\", \")}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst slices: { libraryID: string; sliceID: string }[] = [];\n\t\t\t\t\t\t\t\tfor (const library of libraries) {\n\t\t\t\t\t\t\t\t\tif (library.sliceIDs) {\n\t\t\t\t\t\t\t\t\t\tfor (const sliceID of library.sliceIDs) {\n\t\t\t\t\t\t\t\t\t\t\tslices.push({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (slices.length === 0) {\n\t\t\t\t\t\t\t\t\ttask.skip(\"No slice to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tlet pushed = 0;\n\t\t\t\t\t\t\t\ttask.title = `Pushing slices... (0/${slices.length})`;\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tslices.map(async (slice) => {\n\t\t\t\t\t\t\t\t\t\tawait this.manager.slices.pushSlice(slice);\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing slices... (${pushed}/${slices.length})`;\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttask.title = \"Pushed all slices\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing custom types...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushCustomTypes) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-custom-types used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst { ids, errors } =\n\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.readCustomTypeLibrary();\n\n\t\t\t\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\t\t\t\t// TODO: Provide better error message.\n\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t`Failed to read custom type libraries: ${errors.join(\n\t\t\t\t\t\t\t\t\t\t\t\", \",\n\t\t\t\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (!ids || ids.length === 0) {\n\t\t\t\t\t\t\t\t\ttask.skip(\"No custom type to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tlet pushed = 0;\n\t\t\t\t\t\t\t\ttask.title = `Pushing custom types... (0/${ids.length})`;\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tids.map(async (id) => {\n\t\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.pushCustomType({ id });\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing custom types... (${pushed}/${ids.length})`;\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttask.title = \"Pushed all custom types\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing documents...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushDocuments) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-documents used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tassertExists(\n\t\t\t\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\t\t\t\"Repository selection must be available through context to run `pushDataToPrismic`\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst root = await this.manager.project.getRoot();\n\t\t\t\t\t\t\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait fs.access(documentsDirectoryPath);\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst signaturePath = path.resolve(\n\t\t\t\t\t\t\t\t\tdocumentsDirectoryPath,\n\t\t\t\t\t\t\t\t\t\"index.json\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst rawSignature = await fs.readFile(signaturePath, \"utf-8\");\n\t\t\t\t\t\t\t\tconst signature: string = JSON.parse(rawSignature).signature;\n\n\t\t\t\t\t\t\t\tconst documentsGlob = await globby(\"*/*.json\", {\n\t\t\t\t\t\t\t\t\tcwd: documentsDirectoryPath,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (documentsGlob.length === 0) {\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t\ttask.skip(\"No documents to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst documents: [string, unknown][] = await Promise.all(\n\t\t\t\t\t\t\t\t\tdocumentsGlob.map(async (document) => {\n\t\t\t\t\t\t\t\t\t\tconst filename = path.basename(document, \".json\");\n\t\t\t\t\t\t\t\t\t\tconst fileContent = await fs.readFile(\n\t\t\t\t\t\t\t\t\t\t\tpath.resolve(documentsDirectoryPath, document),\n\t\t\t\t\t\t\t\t\t\t\t\"utf-8\",\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\treturn [filename, JSON.parse(fileContent)];\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.pushDocuments({\n\t\t\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\t\t\tdocuments: Object.fromEntries(documents),\n\t\t\t\t\t\t\t\t\tsignature,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\ttask.title = \"Pushed all documents\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Cleaning up data push artifacts\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst root = await this.manager.project.getRoot();\n\t\t\t\t\t\t\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait fs.rm(documentsDirectoryPath, {\n\t\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t\t\trecursive: true,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t// Noop, it's not that big of a deal if we cannot delete this directory\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttask.title = \"Cleaned up data push artifacts\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\t// TODO: Add Slice Machine script to package.json\n\n\tprotected initializePlugins(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Initializing plugins...\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tconst updateOutput = (data: Buffer | string | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t} else if (typeof data === \"string\") {\n\t\t\t\t\t\t\ttask.output = data;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// TODO: init hook\n\t\t\t\t\tconst { errors } = await this.manager.plugins.dangerouslyCallHook(\n\t\t\t\t\t\t\"command:init\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlog: updateOutput,\n\t\t\t\t\t\t\tinstallDependencies: async (args) => {\n\t\t\t\t\t\t\t\tassertExists(\n\t\t\t\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\t\t\t\"Project package manager must be available through context to run `initializePlugins`\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst { execaProcess } = await installDependencies({\n\t\t\t\t\t\t\t\t\t\t...args,\n\t\t\t\t\t\t\t\t\t\tagent: this.context.packageManager,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\texecaProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t\t\t\t\texecaProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\t\t\t\t\tawait execaProcess;\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t\t\t\t\t\t\"shortMessage\" in error &&\n\t\t\t\t\t\t\t\t\t\t\"stderr\" in error\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tawait this.trackError(error.shortMessage);\n\t\t\t\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${logSymbols.error} Plugins dependency installation failed`,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tawait this.trackError(error);\n\t\t\t\t\t\t\t\t\t\tconsole.error(error);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\t// TODO: Provide better error message.\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Failed to initialize plugins: ${errors.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = \"Initialized plugins\";\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n}\n"],"names":["_","domain"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,MAAM,kBAAkD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,eAAe;;AAGH,MAAA,gCAAgC,CAC5C,YAC4B;AACrB,SAAA,IAAI,wBAAwB,OAAO;AAC3C;MAca,wBAAuB;AAAA,EAMnC,YAAY,SAAwC;AAL1C;AACA;AAEA;AA4EA,sCAAa,CAAC,UAAiC;;AAElD,YAAA,aACL,iBAAiB,QAAQ,MAAM,UAAU,GAAG,SAC3C,MAAM,GAAG,GAAG;AAEP,aAAA,KAAK,QAAQ,UAAU,MAAM;AAAA,QACnC,OAAO;AAAA,QACP,aAAW,UAAK,QAAQ,cAAb,mBAAwB,gBAAe;AAAA,QAClD,aAAY,UAAK,QAAQ,eAAb,mBAAyB;AAAA,QACrC,SAAS;AAAA,QACT,OAAO;AAAA,MAAA,CACP;AAAA,IAAA;AArFD,SAAK,UAAU,EAAE,GAAG,iBAAiB,GAAG,QAAO;AAC/C,SAAK,UAAU,0BAA0B,EAAE,KAAK,mCAAS,KAAK;AAE9D,SAAK,UAAU;EAChB;AAAA,EAEA,MAAM,MAAG;AAGR,YAAQ,IACP;AAAA,EAAK,MAAM,OAAO,IAAI,MAAM,KAAK,MAAM,eAAe,IAAI,KAAK,MAAM,IACpE,GAAG;AAAA,CACsB;AAGrB,UAAA,KAAK,QAAQ,UAAU;AACvB,UAAA,KAAK,QAAQ,UAAU,MAAM;AAAA,MAClC,OAAO;AAAA,MACP,YAA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AAK;AAAA,YACL,qBAAqB,OAAO,SAAQ;;AAElC,2BAAA,KAAK,QAAQ,gBACb,sFAAsF;AAGnF,kBAAA;AACH,sBAAM,EAAE,iBAAiB,MAAM,oBAAoB;AAAA,kBAClD,GAAG;AAAA,kBACH,OAAO,KAAK,QAAQ;AAAA,gBAAA,CACpB;AAEY,mCAAA,WAAA,mBAAQ,GAAG,QAAQ;AACnB,mCAAA,WAAA,mBAAQ,GAAG,QAAQ;AAE1B,sBAAA;AAAA,uBACE;AACR,oBACC,iBAAiB,SACjB,kBAAkB,SAClB,YAAY,OACX;AACK,wBAAA,KAAK,WAAW,MAAM,YAAY;AACxC,0BAAQ,MACP;AAAA;AAAA,EAAO,MAAM;AAAA,EAAiB,MAAM;AAAA;AAAA,EAAa,WAAW,8CAA8C;AAAA,gBAAA,OAErG;AACA,wBAAA,KAAK,WAAW,KAAK;AAC3B,0BAAQ,MAAM,KAAK;AAAA,gBACnB;AAED,wBAAQ,KAAK,CAAC;AAAA,cACd;AAAA,YACF;AAAA,UAAA,CACA;AAGE,cAAA,OAAO,SAAS,GAAG;AAEtB,kBAAM,IAAI,MACT,iCAAiC,OAAO,KAAK,IAAI,GAAG;AAAA,UAErD;AAED,eAAK,QAAQ;AAAA,QACd;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACF;AACA;"}
|
|
1
|
+
{"version":3,"file":"SliceMachineInitProcess.js","sources":["../../src/SliceMachineInitProcess.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport chalk from \"chalk\";\nimport { ExecaChildProcess } from \"execa\";\nimport open from \"open\";\nimport logSymbols from \"log-symbols\";\nimport { globby } from \"globby\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n} from \"@slicemachine/manager\";\n\nimport { detectFramework, Framework } from \"./lib/framework\";\nimport {\n\tinstallDependencies,\n\tdetectPackageManager,\n\tPackageManagerAgent,\n\tgetRunScriptCommand,\n\tgetExecuteCommand,\n} from \"./lib/packageManager\";\nimport {\n\tgetRandomRepositoryDomain,\n\tformatRepositoryDomain,\n\tvalidateRepositoryDomain,\n\tvalidateRepositoryDomainAndAvailability,\n\tgetErrorMessageForRepositoryDomainValidation,\n} from \"./lib/repositoryDomain\";\nimport { listr, listrRun } from \"./lib/listr\";\nimport { prompt } from \"./lib/prompt\";\nimport { assertExists } from \"./lib/assertExists\";\nimport { START_SCRIPT_KEY, START_SCRIPT_VALUE } from \"./constants\";\n\nexport type SliceMachineInitProcessOptions = {\n\trepository?: string;\n\tpush?: boolean;\n\tpushSlices?: boolean;\n\tpushCustomTypes?: boolean;\n\tpushDocuments?: boolean;\n\tcwd?: string;\n} & Record<string, unknown>;\n\nconst DEFAULT_OPTIONS: SliceMachineInitProcessOptions = {\n\tpush: true,\n\tpushSlices: true,\n\tpushCustomTypes: true,\n\tpushDocuments: true,\n};\n\nexport const createSliceMachineInitProcess = (\n\toptions?: SliceMachineInitProcessOptions,\n): SliceMachineInitProcess => {\n\treturn new SliceMachineInitProcess(options);\n};\n\ntype SliceMachineInitProcessContext = {\n\tframework?: Framework;\n\tpackageManager?: PackageManagerAgent;\n\tinstallProcess?: ExecaChildProcess;\n\tuserProfile?: PrismicUserProfile;\n\tuserRepositories?: PrismicRepository[];\n\trepository?: {\n\t\tdomain: string;\n\t\texists: boolean;\n\t};\n\tprojectInitialization?: {\n\t\tpatchedScript?: boolean;\n\t};\n};\n\nexport class SliceMachineInitProcess {\n\tprotected options: SliceMachineInitProcessOptions;\n\tprotected manager: SliceMachineManager;\n\n\tprotected context: SliceMachineInitProcessContext;\n\n\tconstructor(options?: SliceMachineInitProcessOptions) {\n\t\tthis.options = { ...DEFAULT_OPTIONS, ...options };\n\t\tthis.manager = createSliceMachineManager({ cwd: options?.cwd });\n\n\t\tthis.context = {};\n\t}\n\n\tasync run(): Promise<void> {\n\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(\n\t\t\t`\\n${chalk.bgGray(` ${chalk.bold.white(\"Slice Machine\")} `)} ${chalk.dim(\n\t\t\t\t\"→\",\n\t\t\t)} Init command started\\n`,\n\t\t);\n\n\t\tawait this.manager.telemetry.initTelemetry();\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:start\",\n\t\t\trepository: this.options.repository,\n\t\t});\n\n\t\ttry {\n\t\t\tawait this.detectEnvironment();\n\n\t\t\tassertExists(\n\t\t\t\tthis.context.framework,\n\t\t\t\t\"Project framework must be available through context to proceed\",\n\t\t\t);\n\n\t\t\tawait this.beginCoreDependenciesInstallation();\n\t\t\tawait this.loginAndFetchUserData();\n\n\t\t\tif (this.options.repository) {\n\t\t\t\tawait this.useRepositoryFlag();\n\t\t\t} else {\n\t\t\t\tawait this.selectRepository();\n\t\t\t}\n\n\t\t\tassertExists(\n\t\t\t\tthis.context.repository,\n\t\t\t\t\"Repository selection must be available through context to proceed\",\n\t\t\t);\n\n\t\t\tif (!this.context.repository.exists) {\n\t\t\t\tawait this.createNewRepository();\n\t\t\t}\n\n\t\t\tawait this.finishCoreDependenciesInstallation();\n\t\t\tawait this.upsertSliceMachineConfigurationAndStartPluginRunner();\n\t\t\tawait this.pushDataToPrismic();\n\t\t\tawait this.initializeProject();\n\t\t\tawait this.initializePlugins();\n\t\t} catch (error) {\n\t\t\tawait this.trackError(error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework.prismicName,\n\t\t\trepository: this.context.repository.domain,\n\t\t\tsuccess: true,\n\t\t});\n\n\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(\n\t\t\t`\\n${chalk.bgGreen(` ${chalk.bold.white(\"Slice Machine\")} `)} ${chalk.dim(\n\t\t\t\t\"→\",\n\t\t\t)} Init command successful!`,\n\t\t);\n\n\t\ttry {\n\t\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`\n YOUR REPOSITORY\n Dashboard ${chalk.cyan(\n\t\t\t`https://${this.context.repository.domain}.prismic.io`,\n\t\t)}\n API ${chalk.cyan(\n\t\t\t`https://${this.context.repository.domain}.cdn.prismic.io/api/v2`,\n\t\t)}\n\n RESOURCES\n Documentation ${chalk.cyan(\n\t\t\tthis.context.framework.prismicDocumentation,\n\t\t)}\n Getting help ${chalk.cyan(\"https://community.prismic.io\")}\n\n GETTING STARTED\n Start Slice Machine ${chalk.cyan(\n\t\t\tthis.context.projectInitialization?.patchedScript\n\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t })\n\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t }),\n\t\t)}`);\n\t\t} catch {\n\t\t\t// Noop, it's only the final convenience messsage\n\t\t}\n\t}\n\n\tprotected trackError = (error: unknown): Promise<void> => {\n\t\t// Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace\n\t\tconst safeError = (\n\t\t\terror instanceof Error ? error.message : `${error}`\n\t\t).slice(0, 512);\n\n\t\treturn this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework?.prismicName ?? \"unknown\",\n\t\t\trepository: this.context.repository?.domain,\n\t\t\tsuccess: false,\n\t\t\terror: safeError,\n\t\t});\n\t};\n\n\tprotected detectEnvironment(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Detecting environment...\",\n\t\t\t\ttask: (_, parentTask) =>\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Detecting framework...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.framework = await detectFramework(\n\t\t\t\t\t\t\t\t\tthis.manager.cwd,\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttask.title = `Detected framework ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.framework.name,\n\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Detecting package manager...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tthis.context.packageManager = await detectPackageManager(\n\t\t\t\t\t\t\t\t\t\tthis.options.cwd,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\t// Default to NPM\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t\t\t\t\t\t(error.message.match(/failed to detect/i) ||\n\t\t\t\t\t\t\t\t\t\t\terror.message.match(/command failed/i))\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthis.context.packageManager = \"npm\";\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttask.title = `Detected package manager ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\t\t)}`;\n\n\t\t\t\t\t\t\t\tassertExists(\n\t\t\t\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\t\t\t\"Project framework must be available through context to proceed\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tparentTask.title = `Detected framework ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.framework.name,\n\t\t\t\t\t\t\t\t)} and package manager ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected beginCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Beginning core dependencies installation...\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\"Project package manager must be available through context to run `beginCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `beginCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst { execaProcess } = await installDependencies({\n\t\t\t\t\t\tagent: this.context.packageManager,\n\t\t\t\t\t\tdependencies: this.context.framework.devDependencies,\n\t\t\t\t\t\tdev: true,\n\t\t\t\t\t});\n\n\t\t\t\t\t// Fail hard if process fails\n\t\t\t\t\texecaProcess.catch(async (error) => {\n\t\t\t\t\t\tconst [_, ...argv1n] = process.argv;\n\t\t\t\t\t\t// Command the user used\n\t\t\t\t\t\tlet tryAgainCommand = [process.argv0, ...argv1n].join(\" \");\n\n\t\t\t\t\t\t// If the `repository` option wasn't used AND the repository was selected/created\n\t\t\t\t\t\tif (!this.options.repository && this.context.repository) {\n\t\t\t\t\t\t\ttryAgainCommand = `${tryAgainCommand} --repository=${this.context.repository.domain}`;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tawait this.trackError(error.shortMessage);\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${\n\t\t\t\t\t\t\t\tlogSymbols.error\n\t\t\t\t\t\t\t} Dependency installation failed, try again with:\\n\\n ${chalk.gray(\n\t\t\t\t\t\t\t\t\"$\",\n\t\t\t\t\t\t\t)} ${chalk.cyan(tryAgainCommand)}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.installProcess = execaProcess;\n\n\t\t\t\t\ttask.title = `Began core dependencies installation with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)} ... (running in background)`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected loginAndFetchUserData(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Logging in to Prismic...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tparentTask.output = \"Validating session...\";\n\t\t\t\t\tconst isLoggedIn = await this.manager.user.checkIsLoggedIn();\n\n\t\t\t\t\tif (!isLoggedIn) {\n\t\t\t\t\t\tparentTask.output = \"Press any key to open the browser to login...\";\n\t\t\t\t\t\tawait new Promise((resolve) => {\n\t\t\t\t\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\t\t\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\t\t\t\t\tawait this.manager.user.nodeLoginSession({\n\t\t\t\t\t\t\tport,\n\t\t\t\t\t\t\tonListenCallback() {\n\t\t\t\t\t\t\t\topen(url);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tparentTask.output = \"\";\n\t\t\t\t\tparentTask.title = `Logged in`;\n\n\t\t\t\t\treturn listr(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user profile...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\tthis.context.userProfile =\n\t\t\t\t\t\t\t\t\t\tawait this.manager.user.getProfile();\n\n\t\t\t\t\t\t\t\t\tawait this.manager.telemetry.identify({\n\t\t\t\t\t\t\t\t\t\tuserID: this.context.userProfile.shortId,\n\t\t\t\t\t\t\t\t\t\tintercomHash: this.context.userProfile.intercomHash,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tawait this.manager.telemetry.track({\n\t\t\t\t\t\t\t\t\t\tevent: \"command:init:identify\",\n\t\t\t\t\t\t\t\t\t\trepository: this.options.repository,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\tparentTask.title = `Logged in as ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\tthis.context.userProfile?.email,\n\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t\ttask.title = \"Fetched user profile\";\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user repositories...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\tthis.context.userRepositories =\n\t\t\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.readAll();\n\n\t\t\t\t\t\t\t\t\ttask.title = \"Fetched user repositories\";\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\t{ concurrent: true },\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected useRepositoryFlag(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Flag ${chalk.cyan(\"repository\")} used, validating input...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.userRepositories,\n\t\t\t\t\t\t\"User repositories must be available through context to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.options.repository,\n\t\t\t\t\t\t\"Flag `repository` must be set to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst domain = formatRepositoryDomain(this.options.repository);\n\n\t\t\t\t\tconst maybeRepository = this.context.userRepositories.find(\n\t\t\t\t\t\t(repository) => repository.domain === domain,\n\t\t\t\t\t);\n\n\t\t\t\t\tif (maybeRepository) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!this.manager.prismicRepository.hasWriteAccess(maybeRepository)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Cannot run init command with repository ${chalk.cyan(\n\t\t\t\t\t\t\t\t\tmaybeRepository.domain,\n\t\t\t\t\t\t\t\t)}: you are not a developer or admin of this repository`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\t\t\tdomain,\n\t\t\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\t\t\tvalidation,\n\t\t\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (errorMessage) {\n\t\t\t\t\t\t\tthrow new Error(errorMessage);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Selected repository ${chalk.cyan(\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t)} (flag ${chalk.cyan(\"repository\")} used)`;\n\n\t\t\t\t\tthis.context.repository = {\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\texists: !!maybeRepository,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected async selectRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to run `selectRepository`\",\n\t\t);\n\n\t\tif (this.context.userRepositories.length) {\n\t\t\tawait this.trySelectExistingRepository();\n\t\t}\n\n\t\tif (!this.context.repository) {\n\t\t\tawait this.selectNewRepository();\n\t\t}\n\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to proceed\",\n\t\t);\n\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log(\n\t\t\t`${logSymbols.success} Selected repository ${chalk.cyan(\n\t\t\t\tthis.context.repository.domain,\n\t\t\t)}`,\n\t\t);\n\t}\n\n\tprotected async trySelectExistingRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to run `trySelectExistingRepository`\",\n\t\t);\n\n\t\tconst { maybeDomain } = await prompt<string, \"maybeDomain\">({\n\t\t\ttype: \"select\",\n\t\t\tname: \"maybeDomain\",\n\t\t\tmessage: \"Pick a repository to connect to or choose to create a new one\",\n\t\t\twarn: \"You are not a developer or admin of this repository\",\n\t\t\tchoices: [\n\t\t\t\t{\n\t\t\t\t\ttitle: \"CREATE NEW\",\n\t\t\t\t\tdescription: \"Create a new Prismic repository\\n\",\n\t\t\t\t\tvalue: \"\",\n\t\t\t\t},\n\t\t\t\t...this.context.userRepositories\n\t\t\t\t\t.map((repository) => {\n\t\t\t\t\t\tconst hasWriteAccess =\n\t\t\t\t\t\t\tthis.manager.prismicRepository.hasWriteAccess(repository);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttitle: `${repository.domain}${\n\t\t\t\t\t\t\t\thasWriteAccess ? \"\" : \" (Unauthorized)\"\n\t\t\t\t\t\t\t}`,\n\t\t\t\t\t\t\tdescription: `Connect to ${chalk.cyan(repository.domain)}`,\n\t\t\t\t\t\t\tvalue: repository.domain,\n\t\t\t\t\t\t\tdisabled: !hasWriteAccess,\n\t\t\t\t\t\t};\n\t\t\t\t\t})\n\t\t\t\t\t.sort((a, b) => (a.value > b.value ? 1 : -1)),\n\t\t\t],\n\t\t});\n\n\t\tif (maybeDomain) {\n\t\t\tthis.context.repository = {\n\t\t\t\tdomain: maybeDomain,\n\t\t\t\texists: true,\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected async selectNewRepository(): Promise<void> {\n\t\tlet suggestedName = \"\";\n\n\t\t// TODO: Improve concurrency\n\t\tconst trySuggestName = async (name: string): Promise<string | void> => {\n\t\t\tif (name) {\n\t\t\t\tconst formattedName = formatRepositoryDomain(name);\n\n\t\t\t\tif (\n\t\t\t\t\t!validateRepositoryDomain({ domain: formattedName }).hasErrors &&\n\t\t\t\t\t!(await this.manager.prismicRepository.checkExists({\n\t\t\t\t\t\tdomain: formattedName,\n\t\t\t\t\t}))\n\t\t\t\t) {\n\t\t\t\t\treturn formattedName;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t// 1. Try to suggest name after package name\n\t\ttry {\n\t\t\tconst pkgJSONPath = path.join(this.manager.cwd, \"package.json\");\n\t\t\tconst pkg = JSON.parse(await fs.readFile(pkgJSONPath, \"utf-8\"));\n\n\t\t\tconst maybeSuggestion = await trySuggestName(pkg.name);\n\t\t\tif (maybeSuggestion) {\n\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t}\n\t\t} catch {\n\t\t\t// Noop\n\t\t}\n\n\t\t// 2. Try to suggest name after directory name\n\t\tif (!suggestedName) {\n\t\t\tconst maybeSuggestion = await trySuggestName(\n\t\t\t\tpath.basename(this.manager.cwd),\n\t\t\t);\n\t\t\tif (maybeSuggestion) {\n\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t}\n\t\t}\n\n\t\t// 3. Use random name\n\t\tif (!suggestedName) {\n\t\t\tdo {\n\t\t\t\tsuggestedName = getRandomRepositoryDomain();\n\t\t\t} while (\n\t\t\t\tawait this.manager.prismicRepository.checkExists({\n\t\t\t\t\tdomain: suggestedName,\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tconst { domain } = await prompt<string, \"domain\">({\n\t\t\ttype: \"text\",\n\t\t\tname: \"domain\",\n\t\t\t// Overriden by the `onRender` function, just used as a fallback\n\t\t\tmessage: \"Choose a name for your Prismic repository\",\n\t\t\tinitial: suggestedName,\n\t\t\tonRender() {\n\t\t\t\tconst rawDomain = this.value || this.initial || \"\";\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = validateRepositoryDomain({ domain });\n\n\t\t\t\tconst minRule = validation.LessThan4\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"4 characters long or more\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"4 characters long or more\")}`;\n\n\t\t\t\tconst maxRule = validation.MoreThan30\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"30 characters long or less\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"30 characters long or less\")}`;\n\n\t\t\t\tthis.msg = chalk.reset(\n\t\t\t\t\t`\nChoose a name for your Prismic repository\n\n NAMING RULES\n ${minRule}\n ${maxRule}\n 3. Name will be ${chalk.cyan(\"kebab-cased\")} automatically\n\n CONSIDERATIONS\n 1. Once picked, your repository name ${chalk.cyan(\"cannot be changed\")}\n 2. A ${chalk.cyan(\n\t\t\t\"display name\",\n\t\t)} for the repository can be configured later on\n\n PREVIEW\n Dashboard ${chalk.cyan(`https://${domain}.prismic.io`)}\n API ${chalk.cyan(`https://${domain}.cdn.prismic.io/api/v2`)}\n\n${chalk.cyan(\"?\")} Your Prismic repository name`.replace(\"\\n\", \"\"),\n\t\t\t\t);\n\t\t\t},\n\t\t\tvalidate: async (rawDomain: string) => {\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\tdomain,\n\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t});\n\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\tvalidation,\n\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t});\n\n\t\t\t\treturn errorMessage || true;\n\t\t\t},\n\t\t\tformat: (value) => {\n\t\t\t\treturn formatRepositoryDomain(value);\n\t\t\t},\n\t\t});\n\n\t\t// Clear extra lines\n\t\tprocess.stdout.moveCursor?.(0, -16);\n\t\tprocess.stdout.clearScreenDown?.();\n\n\t\tthis.context.repository = {\n\t\t\tdomain,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tprotected createNewRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t);\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Creating new repository ${chalk.cyan(\n\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\tframework: this.context.framework.prismicName,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.title = `Created new repository ${chalk.cyan(\n\t\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected finishCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Finishing core dependencies installation with ${chalk.cyan(\n\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.installProcess,\n\t\t\t\t\t\t\"Initial dependencies installation process must be available through context to run `finishCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst updateOutput = (data: Buffer | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Don't clutter console with logs when process is non TTY (CI, etc.)\n\t\t\t\t\tif (process.stdout.isTTY || process.env.NODE_ENV === \"test\") {\n\t\t\t\t\t\tthis.context.installProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t}\n\t\t\t\t\tthis.context.installProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.context.installProcess;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Error catching happens when then process is started ealier so\n\t\t\t\t\t\t * that all install errors, earlier and presents, can be catched.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * Here, we force the task to wait so that it is neither marked as\n\t\t\t\t\t\t * done or has the opportunity to handle the error itself.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t// If for whatever reason the process is not exited by now, we still throw the error\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 5000));\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Installed core dependencies with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Resolving Slice Machine configuration...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tlet sliceMachineConfigExists = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.manager.project.getSliceMachineConfigPath();\n\t\t\t\t\t\tsliceMachineConfigExists = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// noop, config does not exists, we'll create it\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sliceMachineConfigExists) {\n\t\t\t\t\t\tparentTask.title = \"Updating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst config = await this.manager.project.getSliceMachineConfig();\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tparentTask.title = \"Updated Slice Machine configuration\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentTask.title = \"Creating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst sliceMachineConfigPath =\n\t\t\t\t\t\t\tawait this.manager.project.suggestSliceMachineConfigPath();\n\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t// TODO: Update _latest to a real value or make it optional\n\t\t\t\t\t\t\t\t_latest: \"legacy\",\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t\tlibraries: [\"./slices\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpath: sliceMachineConfigPath,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.title = \"Created Slice Machine configuration\";\n\t\t\t\t\t}\n\n\t\t\t\t\treturn listr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Starting plugin runner...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tawait this.manager.plugins.initPlugins();\n\t\t\t\t\t\t\t\ttask.title = \"Started plugin runner\";\n\t\t\t\t\t\t\t\tparentTask.title = `${parentTask.title} and started plugin runner`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]);\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected pushDataToPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Pushing data to Prismic...\",\n\t\t\t\ttask: (_, parentTask) =>\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing slices...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushSlices) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-slices used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst { libraries, errors } =\n\t\t\t\t\t\t\t\t\tawait this.manager.slices.readAllSliceLibraries();\n\n\t\t\t\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\t\t\t\t// TODO: Provide better error message.\n\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t`Failed to read slice libraries: ${errors.join(\", \")}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst slices: { libraryID: string; sliceID: string }[] = [];\n\t\t\t\t\t\t\t\tfor (const library of libraries) {\n\t\t\t\t\t\t\t\t\tif (library.sliceIDs) {\n\t\t\t\t\t\t\t\t\t\tfor (const sliceID of library.sliceIDs) {\n\t\t\t\t\t\t\t\t\t\t\tslices.push({\n\t\t\t\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\t\t\t\tsliceID,\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (slices.length === 0) {\n\t\t\t\t\t\t\t\t\ttask.skip(\"No slice to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tlet pushed = 0;\n\t\t\t\t\t\t\t\ttask.title = `Pushing slices... (0/${slices.length})`;\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tslices.map(async (slice) => {\n\t\t\t\t\t\t\t\t\t\tawait this.manager.slices.pushSlice(slice);\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing slices... (${pushed}/${slices.length})`;\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttask.title = \"Pushed all slices\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing custom types...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushCustomTypes) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-custom-types used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst { ids, errors } =\n\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.readCustomTypeLibrary();\n\n\t\t\t\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\t\t\t\t// TODO: Provide better error message.\n\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t`Failed to read custom type libraries: ${errors.join(\n\t\t\t\t\t\t\t\t\t\t\t\", \",\n\t\t\t\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (!ids || ids.length === 0) {\n\t\t\t\t\t\t\t\t\ttask.skip(\"No custom type to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tlet pushed = 0;\n\t\t\t\t\t\t\t\ttask.title = `Pushing custom types... (0/${ids.length})`;\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tids.map(async (id) => {\n\t\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.pushCustomType({ id });\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing custom types... (${pushed}/${ids.length})`;\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttask.title = \"Pushed all custom types\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing documents...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushDocuments) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-documents used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tassertExists(\n\t\t\t\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\t\t\t\"Repository selection must be available through context to run `pushDataToPrismic`\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst root = await this.manager.project.getRoot();\n\t\t\t\t\t\t\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait fs.access(documentsDirectoryPath);\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst signaturePath = path.resolve(\n\t\t\t\t\t\t\t\t\tdocumentsDirectoryPath,\n\t\t\t\t\t\t\t\t\t\"index.json\",\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst rawSignature = await fs.readFile(signaturePath, \"utf-8\");\n\t\t\t\t\t\t\t\tconst signature: string = JSON.parse(rawSignature).signature;\n\n\t\t\t\t\t\t\t\tconst documentsGlob = await globby(\"*/*.json\", {\n\t\t\t\t\t\t\t\t\tcwd: documentsDirectoryPath,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (documentsGlob.length === 0) {\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tconst documents: [string, unknown][] = await Promise.all(\n\t\t\t\t\t\t\t\t\tdocumentsGlob.map(async (document) => {\n\t\t\t\t\t\t\t\t\t\tconst filename = path.basename(document, \".json\");\n\t\t\t\t\t\t\t\t\t\tconst fileContent = await fs.readFile(\n\t\t\t\t\t\t\t\t\t\t\tpath.resolve(documentsDirectoryPath, document),\n\t\t\t\t\t\t\t\t\t\t\t\"utf-8\",\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\treturn [filename, JSON.parse(fileContent)];\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.pushDocuments({\n\t\t\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\t\t\tdocuments: Object.fromEntries(documents),\n\t\t\t\t\t\t\t\t\tsignature,\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\ttask.title = \"Pushed all documents\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Cleaning up data push artifacts\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst root = await this.manager.project.getRoot();\n\t\t\t\t\t\t\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait fs.rm(documentsDirectoryPath, {\n\t\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t\t\trecursive: true,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t// Noop, it's not that big of a deal if we cannot delete this directory\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttask.title = \"Cleaned up data push artifacts\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected initializeProject(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Initializing project...\",\n\t\t\t\ttask: async (_, parentTask) =>\n\t\t\t\t\t// We return another Listr instance in the event we have additional task to perform to initialize the project\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: `Patching ${chalk.cyan(\"package.json\")} scripts...`,\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst pkgPath = path.join(this.manager.cwd, \"package.json\");\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst pkgRaw = await fs.readFile(pkgPath, \"utf-8\");\n\t\t\t\t\t\t\t\t\tconst pkg = JSON.parse(pkgRaw);\n\n\t\t\t\t\t\t\t\t\tpkg.scripts ||= {};\n\n\t\t\t\t\t\t\t\t\tif (!pkg.scripts[START_SCRIPT_KEY]) {\n\t\t\t\t\t\t\t\t\t\tpkg.scripts[START_SCRIPT_KEY] = START_SCRIPT_VALUE;\n\n\t\t\t\t\t\t\t\t\t\t// Cheap indent detection based on https://github.com/sindresorhus/detect-indent (simplified because we're only dealing with JSON here)\n\t\t\t\t\t\t\t\t\t\tconst firstIndent = pkgRaw\n\t\t\t\t\t\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t\t\t\t\t\t.find((line) => line.match(/^(?:( )+|\\t+)/));\n\t\t\t\t\t\t\t\t\t\tconst indent = firstIndent?.match(/^(?:( )+|\\t+)/)?.[0];\n\n\t\t\t\t\t\t\t\t\t\tawait fs.writeFile(\n\t\t\t\t\t\t\t\t\t\t\tpkgPath,\n\t\t\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\t\t\tpkg,\n\t\t\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\t\t\tindent && indent !== \" \" ? indent : \" \",\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t!pkg.scripts[\"slicemachine\"].startsWith(START_SCRIPT_VALUE)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Script already exists\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\ttask.title = `Could not patch ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t\t)} scripts (warning)`;\n\t\t\t\t\t\t\t\t\tparentTask.title = `Initialized project (could not patch ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t\t)} scripts)`;\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tthis.context.projectInitialization ||= {};\n\t\t\t\t\t\t\t\tthis.context.projectInitialization.patchedScript = true;\n\n\t\t\t\t\t\t\t\ttask.title = `Patched ${chalk.cyan(\"package.json\")} scripts`;\n\t\t\t\t\t\t\t\tparentTask.title = `Initialized project (patched ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t)} scripts)`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected initializePlugins(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Initializing plugins...\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tconst updateOutput = (data: Buffer | string | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t} else if (typeof data === \"string\") {\n\t\t\t\t\t\t\ttask.output = data;\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// TODO: init hook\n\t\t\t\t\tconst { errors } = await this.manager.plugins.dangerouslyCallHook(\n\t\t\t\t\t\t\"command:init\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlog: updateOutput,\n\t\t\t\t\t\t\tinstallDependencies: async (args) => {\n\t\t\t\t\t\t\t\tassertExists(\n\t\t\t\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t\t\t\t\t\"Project package manager must be available through context to run `initializePlugins`\",\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst { execaProcess } = await installDependencies({\n\t\t\t\t\t\t\t\t\t\t...args,\n\t\t\t\t\t\t\t\t\t\tagent: this.context.packageManager,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\t// Don't clutter console with logs when process is non TTY (CI, etc.)\n\t\t\t\t\t\t\t\t\tif (process.stdout.isTTY || process.env.NODE_ENV === \"test\") {\n\t\t\t\t\t\t\t\t\t\texecaProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\texecaProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\t\t\t\t\tawait execaProcess;\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t\t\t\t\t\t\"shortMessage\" in error &&\n\t\t\t\t\t\t\t\t\t\t\"stderr\" in error\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${logSymbols.error} Plugins dependency installation failed`,\n\t\t\t\t\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\t// TODO: Provide better error message.\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Failed to initialize plugins: ${errors.join(\", \")}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = \"Initialized plugins\";\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n}\n"],"names":["_","_b","_a","domain"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,kBAAkD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,eAAe;;AAGH,MAAA,gCAAgC,CAC5C,YAC4B;AACrB,SAAA,IAAI,wBAAwB,OAAO;AAC3C;MAiBa,wBAAuB;AAAA,EAMnC,YAAY,SAAwC;AAL1C;AACA;AAEA;AA+GA,sCAAa,CAAC,UAAiC;;AAElD,YAAA,aACL,iBAAiB,QAAQ,MAAM,UAAU,GAAG,SAC3C,MAAM,GAAG,GAAG;AAEP,aAAA,KAAK,QAAQ,UAAU,MAAM;AAAA,QACnC,OAAO;AAAA,QACP,aAAW,UAAK,QAAQ,cAAb,mBAAwB,gBAAe;AAAA,QAClD,aAAY,UAAK,QAAQ,eAAb,mBAAyB;AAAA,QACrC,SAAS;AAAA,QACT,OAAO;AAAA,MAAA,CACP;AAAA,IAAA;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H,OAAO,KAAK,QAAQ;AAAA,gBAAA,CACpB;AAGD,oBAAI,QAAQ,OAAO,SAAS,QAAQ,IAAI,aAAa,QAAQ;AAC/C,qCAAA,WAAA,mBAAQ,GAAG,QAAQ;AAAA,gBAChC;AACY,mCAAA,WAAA,mBAAQ,GAAG,QAAQ;AAE1B,sBAAA;AAAA,uBACE;AACR,oBACC,iBAAiB,SACjB,kBAAkB,SAClB,YAAY,OACX;AACD,wBAAM,IAAI,MACT;AAAA;AAAA,EAAO,MAAM;AAAA,EAAiB,MAAM;AAAA;AAAA,EAAa,WAAW,gDAC5D,EAAE,OAAO,OAAO;AAAA,gBAEjB;AAEK,sBAAA;AAAA,cACN;AAAA,YACF;AAAA,UAAA,CACA;AAGE,cAAA,OAAO,SAAS,GAAG;AAEtB,kBAAM,IAAI,MACT,iCAAiC,OAAO,KAAK,IAAI,GAAG;AAAA,UAErD;AAED,eAAK,QAAQ;AAAA,QACd;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACF;AACA;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const index = require("../../../../_virtual/index12.cjs");
|
|
3
3
|
require("../../highlight/lib/index.cjs");
|
|
4
|
-
const index$1 = require("../../../../_virtual/
|
|
4
|
+
const index$1 = require("../../../../_virtual/index13.cjs");
|
|
5
5
|
Object.defineProperty(index.__exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __exports as lib } from "../../../../_virtual/index12.js";
|
|
2
2
|
import "../../highlight/lib/index.js";
|
|
3
|
-
import { __exports as lib$1 } from "../../../../_virtual/
|
|
3
|
+
import { __exports as lib$1 } from "../../../../_virtual/index13.js";
|
|
4
4
|
Object.defineProperty(lib, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const index = require("../../../../_virtual/
|
|
2
|
+
const index = require("../../../../_virtual/index13.cjs");
|
|
3
3
|
require("../../../js-tokens/index.cjs");
|
|
4
4
|
require("../../helper-validator-identifier/lib/index.cjs");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
|
-
const index$1 = require("../../../../_virtual/
|
|
7
|
-
const index$2 = require("../../../../_virtual/
|
|
6
|
+
const index$1 = require("../../../../_virtual/index18.cjs");
|
|
7
|
+
const index$2 = require("../../../../_virtual/index19.cjs");
|
|
8
8
|
Object.defineProperty(index.__exports, "__esModule", {
|
|
9
9
|
value: true
|
|
10
10
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { __exports as lib } from "../../../../_virtual/
|
|
1
|
+
import { __exports as lib } from "../../../../_virtual/index13.js";
|
|
2
2
|
import "../../../js-tokens/index.js";
|
|
3
3
|
import "../../helper-validator-identifier/lib/index.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
import { __exports as jsTokens } from "../../../../_virtual/
|
|
6
|
-
import { __exports as lib$1 } from "../../../../_virtual/
|
|
5
|
+
import { __exports as jsTokens } from "../../../../_virtual/index18.js";
|
|
6
|
+
import { __exports as lib$1 } from "../../../../_virtual/index19.js";
|
|
7
7
|
Object.defineProperty(lib, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|