@slicemachine/init 0.1.1-dev-plugins.3 → 0.1.1-dev-plugins.5
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
|
@@ -19,6 +19,7 @@ const repositoryDomain = require("./lib/repositoryDomain.cjs");
|
|
|
19
19
|
const listr = require("./lib/listr.cjs");
|
|
20
20
|
const prompt = require("./lib/prompt.cjs");
|
|
21
21
|
const assertExists = require("./lib/assertExists.cjs");
|
|
22
|
+
const constants = require("./constants.cjs");
|
|
22
23
|
function _interopNamespaceDefault(e) {
|
|
23
24
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
24
25
|
if (e) {
|
|
@@ -67,6 +68,7 @@ class SliceMachineInitProcess {
|
|
|
67
68
|
this.context = {};
|
|
68
69
|
}
|
|
69
70
|
async run() {
|
|
71
|
+
var _a;
|
|
70
72
|
console.log(`
|
|
71
73
|
${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} Init command started
|
|
72
74
|
`);
|
|
@@ -92,6 +94,7 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
|
|
|
92
94
|
await this.finishCoreDependenciesInstallation();
|
|
93
95
|
await this.upsertSliceMachineConfigurationAndStartPluginRunner();
|
|
94
96
|
await this.pushDataToPrismic();
|
|
97
|
+
await this.initializeProject();
|
|
95
98
|
await this.initializePlugins();
|
|
96
99
|
} catch (error) {
|
|
97
100
|
await this.trackError(error);
|
|
@@ -105,6 +108,26 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
|
|
|
105
108
|
});
|
|
106
109
|
console.log(`
|
|
107
110
|
${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} Init command successful!`);
|
|
111
|
+
try {
|
|
112
|
+
console.log(`
|
|
113
|
+
YOUR REPOSITORY
|
|
114
|
+
Dashboard ${chalk.cyan(`https://${this.context.repository.domain}.prismic.io`)}
|
|
115
|
+
API ${chalk.cyan(`https://${this.context.repository.domain}.cdn.prismic.io/api/v2`)}
|
|
116
|
+
|
|
117
|
+
RESOURCES
|
|
118
|
+
Documentation ${chalk.cyan(this.context.framework.prismicDocumentation)}
|
|
119
|
+
Getting help ${chalk.cyan("https://community.prismic.io")}
|
|
120
|
+
|
|
121
|
+
GETTING STARTED
|
|
122
|
+
Start Slice Machine ${chalk.cyan(((_a = this.context.projectInitialization) == null ? void 0 : _a.patchedScript) ? await packageManager.getRunScriptCommand({
|
|
123
|
+
agent: this.context.packageManager || "npm",
|
|
124
|
+
script: "slicemachine"
|
|
125
|
+
}) : await packageManager.getExecuteCommand({
|
|
126
|
+
agent: this.context.packageManager || "npm",
|
|
127
|
+
script: "start-slicemachine"
|
|
128
|
+
}))}`);
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
108
131
|
}
|
|
109
132
|
detectEnvironment() {
|
|
110
133
|
return listr.listrRun([
|
|
@@ -121,7 +144,15 @@ ${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} I
|
|
|
121
144
|
{
|
|
122
145
|
title: "Detecting package manager...",
|
|
123
146
|
task: async (_2, task) => {
|
|
124
|
-
|
|
147
|
+
try {
|
|
148
|
+
this.context.packageManager = await packageManager.detectPackageManager(this.options.cwd);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (error instanceof Error && (error.message.match(/failed to detect/i) || error.message.match(/command failed/i))) {
|
|
151
|
+
this.context.packageManager = "npm";
|
|
152
|
+
} else {
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
125
156
|
task.title = `Detected package manager ${chalk.cyan(this.context.packageManager)}`;
|
|
126
157
|
assertExists.assertExists(this.context.framework, "Project framework must be available through context to proceed");
|
|
127
158
|
parentTask.title = `Detected framework ${chalk.cyan(this.context.framework.name)} and package manager ${chalk.cyan(this.context.packageManager)}`;
|
|
@@ -176,10 +207,12 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
176
207
|
if (!isLoggedIn) {
|
|
177
208
|
parentTask.output = "Press any key to open the browser to login...";
|
|
178
209
|
await new Promise((resolve) => {
|
|
179
|
-
|
|
180
|
-
process.stdin.
|
|
210
|
+
var _a, _b;
|
|
211
|
+
const initialRawMode = !!process.stdin.isRaw;
|
|
212
|
+
(_b = (_a = process.stdin).setRawMode) == null ? void 0 : _b.call(_a, true);
|
|
181
213
|
process.stdin.once("data", (data) => {
|
|
182
|
-
|
|
214
|
+
var _a2, _b2;
|
|
215
|
+
(_b2 = (_a2 = process.stdin).setRawMode) == null ? void 0 : _b2.call(_a2, initialRawMode);
|
|
183
216
|
process.stdin.pause();
|
|
184
217
|
resolve(data.toString("utf-8"));
|
|
185
218
|
});
|
|
@@ -189,9 +222,7 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
189
222
|
await this.manager.user.nodeLoginSession({
|
|
190
223
|
port,
|
|
191
224
|
onListenCallback() {
|
|
192
|
-
open(url)
|
|
193
|
-
throw error;
|
|
194
|
-
});
|
|
225
|
+
open(url);
|
|
195
226
|
}
|
|
196
227
|
});
|
|
197
228
|
}
|
|
@@ -234,13 +265,13 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
234
265
|
task: async (_, task) => {
|
|
235
266
|
assertExists.assertExists(this.context.userRepositories, "User repositories must be available through context to run `useRepositoryFlag`");
|
|
236
267
|
assertExists.assertExists(this.options.repository, "Flag `repository` must be set to run `useRepositoryFlag`");
|
|
237
|
-
const
|
|
268
|
+
const domain = repositoryDomain.formatRepositoryDomain(this.options.repository);
|
|
269
|
+
const maybeRepository = this.context.userRepositories.find((repository) => repository.domain === domain);
|
|
238
270
|
if (maybeRepository) {
|
|
239
271
|
if (!this.manager.prismicRepository.hasWriteAccess(maybeRepository)) {
|
|
240
272
|
throw new Error(`Cannot run init command with repository ${chalk.cyan(maybeRepository.domain)}: you are not a developer or admin of this repository`);
|
|
241
273
|
}
|
|
242
274
|
} else {
|
|
243
|
-
const domain = repositoryDomain.formatRepositoryDomain(this.options.repository);
|
|
244
275
|
const validation = await repositoryDomain.validateRepositoryDomainAndAvailability({
|
|
245
276
|
domain,
|
|
246
277
|
existsFn: (domain2) => this.manager.prismicRepository.checkExists({ domain: domain2 })
|
|
@@ -253,9 +284,9 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
253
284
|
throw new Error(errorMessage);
|
|
254
285
|
}
|
|
255
286
|
}
|
|
256
|
-
task.title = `Selected repository ${chalk.cyan(
|
|
287
|
+
task.title = `Selected repository ${chalk.cyan(domain)} (flag ${chalk.cyan("repository")} used)`;
|
|
257
288
|
this.context.repository = {
|
|
258
|
-
domain
|
|
289
|
+
domain,
|
|
259
290
|
exists: !!maybeRepository
|
|
260
291
|
};
|
|
261
292
|
}
|
|
@@ -305,6 +336,7 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
305
336
|
}
|
|
306
337
|
}
|
|
307
338
|
async selectNewRepository() {
|
|
339
|
+
var _a, _b, _c, _d;
|
|
308
340
|
let suggestedName = "";
|
|
309
341
|
const trySuggestName = async (name) => {
|
|
310
342
|
if (name) {
|
|
@@ -332,12 +364,11 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
332
364
|
}
|
|
333
365
|
}
|
|
334
366
|
if (!suggestedName) {
|
|
335
|
-
|
|
336
|
-
while (await this.manager.prismicRepository.checkExists({
|
|
337
|
-
domain: suggestedName
|
|
338
|
-
})) {
|
|
367
|
+
do {
|
|
339
368
|
suggestedName = repositoryDomain.getRandomRepositoryDomain();
|
|
340
|
-
}
|
|
369
|
+
} while (await this.manager.prismicRepository.checkExists({
|
|
370
|
+
domain: suggestedName
|
|
371
|
+
}));
|
|
341
372
|
}
|
|
342
373
|
const { domain } = await prompt.prompt({
|
|
343
374
|
type: "text",
|
|
@@ -349,21 +380,23 @@ ${logSymbols.error} Dependency installation failed, try again with:
|
|
|
349
380
|
const rawDomain = this.value || this.initial || "";
|
|
350
381
|
const domain2 = repositoryDomain.formatRepositoryDomain(rawDomain);
|
|
351
382
|
const validation = repositoryDomain.validateRepositoryDomain({ domain: domain2 });
|
|
383
|
+
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")}`;
|
|
384
|
+
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")}`;
|
|
352
385
|
this.msg = chalk.reset(`
|
|
353
386
|
Choose a name for your Prismic repository
|
|
354
387
|
|
|
355
388
|
NAMING RULES
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
389
|
+
${minRule}
|
|
390
|
+
${maxRule}
|
|
391
|
+
3. Name will be ${chalk.cyan("kebab-cased")} automatically
|
|
359
392
|
|
|
360
393
|
CONSIDERATIONS
|
|
361
|
-
|
|
362
|
-
|
|
394
|
+
1. Once picked, your repository name ${chalk.cyan("cannot be changed")}
|
|
395
|
+
2. A ${chalk.cyan("display name")} for the repository can be configured later on
|
|
363
396
|
|
|
364
397
|
PREVIEW
|
|
365
|
-
|
|
366
|
-
|
|
398
|
+
Dashboard ${chalk.cyan(`https://${domain2}.prismic.io`)}
|
|
399
|
+
API ${chalk.cyan(`https://${domain2}.cdn.prismic.io/api/v2`)}
|
|
367
400
|
|
|
368
401
|
${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
369
402
|
},
|
|
@@ -383,8 +416,8 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
383
416
|
return repositoryDomain.formatRepositoryDomain(value);
|
|
384
417
|
}
|
|
385
418
|
});
|
|
386
|
-
process.stdout.moveCursor(0, -16);
|
|
387
|
-
process.stdout.clearScreenDown();
|
|
419
|
+
(_b = (_a = process.stdout).moveCursor) == null ? void 0 : _b.call(_a, 0, -16);
|
|
420
|
+
(_d = (_c = process.stdout).clearScreenDown) == null ? void 0 : _d.call(_c);
|
|
388
421
|
this.context.repository = {
|
|
389
422
|
domain,
|
|
390
423
|
exists: false
|
|
@@ -420,18 +453,17 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
420
453
|
task.output = data.toString();
|
|
421
454
|
}
|
|
422
455
|
};
|
|
423
|
-
(
|
|
456
|
+
if (process.stdout.isTTY || process.env.NODE_ENV === "test") {
|
|
457
|
+
(_a = this.context.installProcess.stdout) == null ? void 0 : _a.on("data", updateOutput);
|
|
458
|
+
}
|
|
424
459
|
(_b = this.context.installProcess.stderr) == null ? void 0 : _b.on("data", updateOutput);
|
|
425
460
|
try {
|
|
426
461
|
await this.context.installProcess;
|
|
427
462
|
} catch (error) {
|
|
428
|
-
await new Promise(() =>
|
|
429
|
-
|
|
430
|
-
throw error;
|
|
431
|
-
}, 5e3);
|
|
432
|
-
});
|
|
463
|
+
await new Promise((resolve) => setTimeout(resolve, 5e3));
|
|
464
|
+
throw error;
|
|
433
465
|
}
|
|
434
|
-
task.title = `
|
|
466
|
+
task.title = `Installed core dependencies with ${chalk.cyan(this.context.packageManager)}`;
|
|
435
467
|
}
|
|
436
468
|
}
|
|
437
469
|
]);
|
|
@@ -455,7 +487,8 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
455
487
|
await this.manager.project.writeSliceMachineConfig({
|
|
456
488
|
config: {
|
|
457
489
|
...config,
|
|
458
|
-
repositoryName: this.context.repository.domain
|
|
490
|
+
repositoryName: this.context.repository.domain,
|
|
491
|
+
adapter: this.context.framework.adapterName
|
|
459
492
|
}
|
|
460
493
|
});
|
|
461
494
|
parentTask.title = "Updated Slice Machine configuration";
|
|
@@ -588,7 +621,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
588
621
|
});
|
|
589
622
|
if (documentsGlob.length === 0) {
|
|
590
623
|
parentTask.title = "Pushed data to Prismic";
|
|
591
|
-
task.skip("No
|
|
624
|
+
task.skip("No document to push");
|
|
592
625
|
return;
|
|
593
626
|
}
|
|
594
627
|
const documents = await Promise.all(documentsGlob.map(async (document) => {
|
|
@@ -625,7 +658,44 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
625
658
|
}
|
|
626
659
|
]);
|
|
627
660
|
}
|
|
628
|
-
|
|
661
|
+
initializeProject() {
|
|
662
|
+
return listr.listrRun([
|
|
663
|
+
{
|
|
664
|
+
title: "Initializing project...",
|
|
665
|
+
task: async (_, parentTask) => // We return another Listr instance in the event we have additional task to perform to initialize the project
|
|
666
|
+
listr.listr([
|
|
667
|
+
{
|
|
668
|
+
title: `Patching ${chalk.cyan("package.json")} scripts...`,
|
|
669
|
+
task: async (_2, task) => {
|
|
670
|
+
var _a, _b;
|
|
671
|
+
const pkgPath = path__namespace.join(this.manager.cwd, "package.json");
|
|
672
|
+
try {
|
|
673
|
+
const pkgRaw = await fs__namespace.readFile(pkgPath, "utf-8");
|
|
674
|
+
const pkg = JSON.parse(pkgRaw);
|
|
675
|
+
pkg.scripts || (pkg.scripts = {});
|
|
676
|
+
if (!pkg.scripts[constants.START_SCRIPT_KEY]) {
|
|
677
|
+
pkg.scripts[constants.START_SCRIPT_KEY] = constants.START_SCRIPT_VALUE;
|
|
678
|
+
const firstIndent = pkgRaw.split("\n").find((line) => line.match(/^(?:( )+|\t+)/));
|
|
679
|
+
const indent = (_a = firstIndent == null ? void 0 : firstIndent.match(/^(?:( )+|\t+)/)) == null ? void 0 : _a[0];
|
|
680
|
+
await fs__namespace.writeFile(pkgPath, JSON.stringify(pkg, null, indent && indent !== " " ? indent : " "));
|
|
681
|
+
} else if (!pkg.scripts["slicemachine"].startsWith(constants.START_SCRIPT_VALUE)) {
|
|
682
|
+
throw new Error("Script already exists");
|
|
683
|
+
}
|
|
684
|
+
} catch (error) {
|
|
685
|
+
task.title = `Could not patch ${chalk.cyan("package.json")} scripts (warning)`;
|
|
686
|
+
parentTask.title = `Initialized project (could not patch ${chalk.cyan("package.json")} scripts)`;
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
(_b = this.context).projectInitialization || (_b.projectInitialization = {});
|
|
690
|
+
this.context.projectInitialization.patchedScript = true;
|
|
691
|
+
task.title = `Patched ${chalk.cyan("package.json")} scripts`;
|
|
692
|
+
parentTask.title = `Initialized project (patched ${chalk.cyan("package.json")} scripts)`;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
])
|
|
696
|
+
}
|
|
697
|
+
]);
|
|
698
|
+
}
|
|
629
699
|
initializePlugins() {
|
|
630
700
|
return listr.listrRun([
|
|
631
701
|
{
|
|
@@ -648,23 +718,21 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
648
718
|
...args,
|
|
649
719
|
agent: this.context.packageManager
|
|
650
720
|
});
|
|
651
|
-
(
|
|
721
|
+
if (process.stdout.isTTY || process.env.NODE_ENV === "test") {
|
|
722
|
+
(_a = execaProcess.stdout) == null ? void 0 : _a.on("data", updateOutput);
|
|
723
|
+
}
|
|
652
724
|
(_b = execaProcess.stderr) == null ? void 0 : _b.on("data", updateOutput);
|
|
653
725
|
await execaProcess;
|
|
654
726
|
} catch (error) {
|
|
655
727
|
if (error instanceof Error && "shortMessage" in error && "stderr" in error) {
|
|
656
|
-
|
|
657
|
-
console.error(`
|
|
728
|
+
throw new Error(`
|
|
658
729
|
|
|
659
730
|
${error.shortMessage}
|
|
660
731
|
${error.stderr}
|
|
661
732
|
|
|
662
|
-
${logSymbols.error} Plugins dependency installation failed
|
|
663
|
-
} else {
|
|
664
|
-
await this.trackError(error);
|
|
665
|
-
console.error(error);
|
|
733
|
+
${logSymbols.error} Plugins dependency installation failed`, { cause: error });
|
|
666
734
|
}
|
|
667
|
-
|
|
735
|
+
throw error;
|
|
668
736
|
}
|
|
669
737
|
}
|
|
670
738
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceMachineInitProcess.cjs","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":["createSliceMachineManager","assertExists","listrRun","listr","_","detectFramework","detectPackageManager","installDependencies","formatRepositoryDomain","validateRepositoryDomainAndAvailability","domain","getErrorMessageForRepositoryDomainValidation","prompt","validateRepositoryDomain","path","fs","getRandomRepositoryDomain","globby"],"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,UAAUA,kCAA0B,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,YAAY,KAAK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AAAA,QACP,MAAM,OAAO,GAAG,SAAQ;AACjB,gBAAA,eAAe,CAAC,SAAgC;AACrD,gBAAI,gBAAgB,QAAQ;AACtB,mBAAA,SAAS,KAAK;uBACT,OAAO,SAAS,UAAU;AACpC,mBAAK,SAAS;AAAA,YACd;AAAA,UAAA;AAII,gBAAA,EAAE,WAAW,MAAM,KAAK,QAAQ,QAAQ,oBAC7C,gBACA;AAAA,YACC,KAAK;AAAA,YACL,qBAAqB,OAAO,SAAQ;;AAElCD,2BAAAA,aAAA,KAAK,QAAQ,gBACb,sFAAsF;AAGnF,kBAAA;AACH,sBAAM,EAAE,iBAAiB,MAAMM,mCAAoB;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.cjs","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":["createSliceMachineManager","assertExists","getRunScriptCommand","getExecuteCommand","listrRun","listr","_","detectFramework","detectPackageManager","installDependencies","_b","_a","formatRepositoryDomain","validateRepositoryDomainAndAvailability","domain","getErrorMessageForRepositoryDomainValidation","prompt","validateRepositoryDomain","path","fs","getRandomRepositoryDomain","globby","START_SCRIPT_KEY","START_SCRIPT_VALUE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,kBAAkD;AAAA,EACvD,MAAM;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AEjB;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;;;"}
|
|
@@ -21,6 +21,9 @@ type SliceMachineInitProcessContext = {
|
|
|
21
21
|
domain: string;
|
|
22
22
|
exists: boolean;
|
|
23
23
|
};
|
|
24
|
+
projectInitialization?: {
|
|
25
|
+
patchedScript?: boolean;
|
|
26
|
+
};
|
|
24
27
|
};
|
|
25
28
|
export declare class SliceMachineInitProcess {
|
|
26
29
|
protected options: SliceMachineInitProcessOptions;
|
|
@@ -40,6 +43,7 @@ export declare class SliceMachineInitProcess {
|
|
|
40
43
|
protected finishCoreDependenciesInstallation(): Promise<void>;
|
|
41
44
|
protected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void>;
|
|
42
45
|
protected pushDataToPrismic(): Promise<void>;
|
|
46
|
+
protected initializeProject(): Promise<void>;
|
|
43
47
|
protected initializePlugins(): Promise<void>;
|
|
44
48
|
}
|
|
45
49
|
export {};
|