@slicemachine/init 2.9.3-dev-environments.5 → 2.9.3-dev-next-release.2
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 +8 -2
- package/dist/SliceMachineInitProcess.cjs.map +1 -1
- package/dist/SliceMachineInitProcess.js +8 -2
- package/dist/SliceMachineInitProcess.js.map +1 -1
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.cjs +89 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.cjs.map +1 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.js +90 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.js.map +1 -0
- package/dist/_node_modules/p-limit/index.cjs +53 -0
- package/dist/_node_modules/p-limit/index.cjs.map +1 -0
- package/dist/_node_modules/p-limit/index.js +54 -0
- package/dist/_node_modules/p-limit/index.js.map +1 -0
- package/dist/packages/init/package.json.cjs +5 -4
- package/dist/packages/init/package.json.cjs.map +1 -1
- package/dist/packages/init/package.json.js +5 -4
- package/dist/packages/init/package.json.js.map +1 -1
- package/package.json +5 -4
- package/src/SliceMachineInitProcess.ts +11 -2
|
@@ -14,6 +14,7 @@ const open = require("open");
|
|
|
14
14
|
const logSymbols = require("log-symbols");
|
|
15
15
|
const index$1 = require('./_node_modules/globby/index.cjs');
|
|
16
16
|
const giget = require("giget");
|
|
17
|
+
const index$2 = require('./_node_modules/p-limit/index.cjs');
|
|
17
18
|
const manager = require("@slicemachine/manager");
|
|
18
19
|
const _package = require("./packages/init/package.json.cjs");
|
|
19
20
|
const framework = require("./lib/framework.cjs");
|
|
@@ -152,7 +153,7 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
|
|
|
152
153
|
});
|
|
153
154
|
console.log(`
|
|
154
155
|
${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} Initialization successful!
|
|
155
|
-
|
|
156
|
+
|
|
156
157
|
Continue with next steps in Slice Machine.
|
|
157
158
|
`);
|
|
158
159
|
try {
|
|
@@ -859,8 +860,13 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
859
860
|
return;
|
|
860
861
|
}
|
|
861
862
|
const remoteTypes = await this.manager.customTypes.fetchRemoteCustomTypes();
|
|
863
|
+
const createCustomTypeLimit = index$2(8);
|
|
864
|
+
let pulled = 0;
|
|
865
|
+
task.title = `Pulling existing types... (0/${remoteTypes.length})`;
|
|
862
866
|
await Promise.all(remoteTypes.map(async (model) => {
|
|
863
|
-
await this.manager.customTypes.createCustomType({ model });
|
|
867
|
+
await createCustomTypeLimit(() => this.manager.customTypes.createCustomType({ model }));
|
|
868
|
+
pulled++;
|
|
869
|
+
task.title = `Pulling existing types... (${pulled}/${remoteTypes.length})`;
|
|
864
870
|
}));
|
|
865
871
|
task.title = "Pulled existing types";
|
|
866
872
|
parentTask.title = "Synced data with Prismic";
|
|
@@ -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\";\n\nimport { execaCommand, type ExecaChildProcess } from \"execa\";\n\nimport open from \"open\";\nimport logSymbols from \"log-symbols\";\nimport { globby } from \"globby\";\nimport { downloadTemplate } from \"giget\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n\tPackageManager,\n\tStarterId,\n\tREPOSITORY_NAME_VALIDATION,\n} from \"@slicemachine/manager\";\n\nimport pkg from \"../package.json\";\nimport { detectFramework, Framework } from \"./lib/framework\";\nimport { getRunScriptCommand } from \"./lib/getRunScriptCommand\";\nimport { getExecuteCommand } from \"./lib/getExecuteCommand\";\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 {\n\tGIGET_ORGANIZATION,\n\tGIGET_PROVIDER,\n\tSLICE_MACHINE_INIT_USER_AGENT,\n\tSTART_SCRIPT_KEY,\n\tSTART_SCRIPT_VALUE,\n} from \"./constants\";\nimport { detectStarterId } from \"./lib/starters\";\nimport { setupSentry } from \"./lib/setupSentry\";\nimport { trackSentryError } from \"./lib/sentryErrorHandlers\";\nimport { updateSentryContext } from \"./lib/updateSentryContext\";\n\nexport type SliceMachineInitProcessOptions = {\n\trepository?: string;\n\tstarter?: string;\n\tdirectoryName?: string;\n\tpush?: boolean;\n\tpushSlices?: boolean;\n\tpushCustomTypes?: boolean;\n\tpushDocuments?: boolean;\n\tstartSlicemachine?: 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\tstartSlicemachine: 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?: PackageManager;\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\tstarterId?: StarterId;\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)} Initializing\\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.starter) {\n\t\t\t\tawait this.copyStarter();\n\t\t\t} else if (this.options.directoryName) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${logSymbols.warning} --directory-name has no effect because --starter is not specified\\n`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (await this.manager.telemetry.checkIsTelemetryEnabled()) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${\n\t\t\t\t\t\tlogSymbols.info\n\t\t\t\t\t} We collect telemetry data to improve user experience.\\n Learn more: ${chalk.cyan(\n\t\t\t\t\t\t\"https://prismic.dev/slice-machine/telemetry\",\n\t\t\t\t\t)}\\n`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.manager.telemetry.initTelemetry({\n\t\t\t\tappName: pkg.name,\n\t\t\t\tappVersion: pkg.version,\n\t\t\t});\n\t\t\tawait setupSentry();\n\t\t\tawait this.manager.telemetry.track({\n\t\t\t\tevent: \"command:init:start\",\n\t\t\t\trepository: this.options.repository,\n\t\t\t});\n\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\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.loginAndFetchUserData();\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\tawait this.finishCoreDependenciesInstallation();\n\t\t\tawait this.upsertSliceMachineConfigurationAndStartPluginRunner();\n\n\t\t\tconst isLoginRequired = await this.checkIsLoginRequired();\n\t\t\tif (isLoginRequired) {\n\t\t\t\tawait this.loginAndFetchUserData();\n\t\t\t\tif (this.context.repository.exists) {\n\t\t\t\t\tthis.validateWriteAccess();\n\t\t\t\t}\n\t\t\t}\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.syncDataWithPrismic();\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.sliceMachineTelemetryID,\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)} Initialization successful!\n\t\t\t\nContinue with next steps in Slice Machine.\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.startSlicemachine) {\n\t\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t\t })\n\t\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t\t });\n\n\t\t\t\tconst { startSlicemachine } = await prompt<\n\t\t\t\t\tboolean,\n\t\t\t\t\t\"startSlicemachine\"\n\t\t\t\t>({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"startSlicemachine\",\n\t\t\t\t\tmessage: `Run Slice Machine (${chalk.cyan(runSmCommand)})?`,\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (startSlicemachine) {\n\t\t\t\t\tconst commandReturnValue = await execaCommand(runSmCommand, {\n\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t}).pipeStdout?.(process.stdout);\n\t\t\t\t\tif (commandReturnValue !== undefined) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.log(commandReturnValue.stdout);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Only track this error with Sentry, it's only the final convenience message\n\t\t\tawait this.trackSentryError(error);\n\t\t}\n\t}\n\n\tprotected async checkIsLoginRequired(): Promise<boolean> {\n\t\ttry {\n\t\t\tassertExists(this.context.repository, \"\");\n\t\t\tif (this.context.repository.exists === false) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst [slices, ctLibrary, documentsGlob] = await Promise.all([\n\t\t\t\tthis.readAllSlices(),\n\t\t\t\tthis.manager.customTypes.readCustomTypeLibrary(),\n\t\t\t\tthis.readDocuments(),\n\t\t\t]);\n\n\t\t\t// If repository exists, and there's anything to push\n\t\t\tif (\n\t\t\t\tslices.length > 0 ||\n\t\t\t\tctLibrary.ids.length > 0 ||\n\t\t\t\t(documentsGlob !== undefined && documentsGlob.documents.length > 0)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// If repository exists, and there might be things to pull\n\t\t\tif (ctLibrary.ids.length === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected trackError = async (error: unknown): Promise<void> => {\n\t\tawait this.trackSentryError(error);\n\t\tawait this.trackTelemetryError(error);\n\t};\n\n\tprotected trackTelemetryError = async (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\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"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 trackSentryError = async (error: unknown): Promise<void> => {\n\t\tawait updateSentryContext({\n\t\t\tmanager: this.manager,\n\t\t\trepositoryName: this.context.repository?.domain || \"\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"unknown\",\n\t\t});\n\t\ttrackSentryError(error);\n\t};\n\n\tprotected async copyStarter(): Promise<void> {\n\t\tconst dir = await this.getStarterDirectoryName();\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Copying starter...\\n\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tconst starter = this.options.starter;\n\n\t\t\t\t\tawait downloadTemplate(\n\t\t\t\t\t\t`${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tprocess.chdir(dir);\n\t\t\t\t\tthis.manager.cwd = process.cwd();\n\n\t\t\t\t\ttask.title = \"Starter copied\\n\";\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected async getStarterDirectoryName(): Promise<string> {\n\t\tlet directoryName: string;\n\t\tconst folderNames = await fs.readdir(process.cwd());\n\n\t\tif (\n\t\t\tthis.options.directoryName &&\n\t\t\t!folderNames.includes(this.options.directoryName)\n\t\t) {\n\t\t\t// Use provided directory\n\t\t\tdirectoryName = this.options.directoryName;\n\t\t} else if (\n\t\t\tthis.options.repository &&\n\t\t\t!folderNames.includes(this.options.repository)\n\t\t) {\n\t\t\t// Use repository name\n\t\t\tdirectoryName = this.options.repository;\n\t\t} else {\n\t\t\t// Use random name\n\t\t\tlet suggestedName: string;\n\t\t\tdo {\n\t\t\t\tsuggestedName = getRandomRepositoryDomain();\n\t\t\t} while (folderNames.includes(suggestedName));\n\n\t\t\tconst { selectedDirectory } = await prompt<string, \"selectedDirectory\">({\n\t\t\t\ttype: \"text\",\n\t\t\t\tname: \"selectedDirectory\",\n\t\t\t\tmessage: \"Your starter directory name\",\n\t\t\t\tinitial: suggestedName,\n\t\t\t\tvalidate: async (rawDirectory: string) => {\n\t\t\t\t\tif (folderNames.includes(rawDirectory)) {\n\t\t\t\t\t\treturn \"Directory name already exists\";\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tdirectoryName = selectedDirectory;\n\t\t}\n\n\t\treturn directoryName;\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 =\n\t\t\t\t\t\t\t\t\tawait this.manager.project.detectPackageManager({\n\t\t\t\t\t\t\t\t\t\troot: this.manager.cwd,\n\t\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\t{\n\t\t\t\t\t\t\ttitle: \"Detecting starter...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.starterId = await detectStarterId(\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\tif (this.context.starterId) {\n\t\t\t\t\t\t\t\t\ttask.title = `Detected starter ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\tthis.context.starterId,\n\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\ttask.title = \"No starter detected\";\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 } =\n\t\t\t\t\t\tawait this.manager.project.installDependencies({\n\t\t\t\t\t\t\tpackageManager: this.context.packageManager,\n\t\t\t\t\t\t\tdependencies: this.context.framework.devDependencies,\n\t\t\t\t\t\t\tdev: true,\n\t\t\t\t\t\t\t// Picked up later\n\t\t\t\t\t\t\tlog: () => {\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\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);\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 async fetchUserProfile(): Promise<void> {\n\t\tthis.context.userProfile = await this.manager.user.getProfile();\n\n\t\tawait this.manager.telemetry.identify({\n\t\t\tuserID: this.context.userProfile.shortId,\n\t\t\tintercomHash: this.context.userProfile.intercomHash,\n\t\t});\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:identify\",\n\t\t\trepository: this.options.repository,\n\t\t});\n\t}\n\n\tprotected async fetchUserRepositories(): Promise<void> {\n\t\tthis.context.userRepositories =\n\t\t\tawait this.manager.prismicRepository.readAll();\n\t}\n\n\tprotected validateWriteAccess(): void {\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\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to validate write access\",\n\t\t);\n\t\tconst { domain } = this.context.repository;\n\t\tconst maybeRepository = this.context.userRepositories.find(\n\t\t\t(repository) => repository.domain === domain,\n\t\t);\n\n\t\tif (maybeRepository) {\n\t\t\tif (!this.manager.prismicRepository.hasWriteAccess(maybeRepository)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot run init command with repository ${chalk.cyan(\n\t\t\t\t\t\tmaybeRepository.domain,\n\t\t\t\t\t)}: you are not a developer or admin of this repository`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot validate write access for repository ${chalk.cyan(\n\t\t\t\t\tdomain,\n\t\t\t\t)}: you are not part of this repository`,\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 this.pressKeyToLogin();\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\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\tawait this.fetchUserProfile();\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\tawait this.fetchUserRepositories();\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 async pressKeyToLogin(): Promise<void> {\n\t\tawait new Promise((resolve) => {\n\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\tprocess.stdin.resume();\n\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\tprocess.stdin.pause();\n\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t});\n\t\t});\n\t}\n\n\tprotected async waitingForLogin(): Promise<void> {\n\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\tawait this.manager.user.nodeLoginSession({\n\t\t\tport,\n\t\t\tonListenCallback() {\n\t\t\t\topen(url);\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.options.repository,\n\t\t\t\t\t\t\"Flag `repository` must be set to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\t\t\t\t\tconst domain = formatRepositoryDomain(this.options.repository);\n\t\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t\t});\n\n\t\t\t\t\tif (validation.LessThanMin || validation.MoreThanMax) {\n\t\t\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\t\t\tvalidation: {\n\t\t\t\t\t\t\t\t...validation,\n\t\t\t\t\t\t\t\t// We don't want to throw if repo already exists.\n\t\t\t\t\t\t\t\t// User most probably just created it via their dashboard.\n\t\t\t\t\t\t\t\tAlreadyExists: false,\n\t\t\t\t\t\t\t},\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: validation.AlreadyExists ?? false,\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 directory name\n\t\tconst maybeSuggestion = await trySuggestName(\n\t\t\tpath.basename(this.manager.cwd),\n\t\t);\n\t\tif (maybeSuggestion) {\n\t\t\tsuggestedName = maybeSuggestion;\n\t\t}\n\n\t\t// 2. Try to suggest name after package name\n\t\tif (!suggestedName) {\n\t\t\ttry {\n\t\t\t\tconst pkgJSONPath = path.join(this.manager.cwd, \"package.json\");\n\t\t\t\tconst pkg = JSON.parse(await fs.readFile(pkgJSONPath, \"utf-8\"));\n\n\t\t\t\tconst maybeSuggestion = await trySuggestName(pkg.name);\n\t\t\t\tif (maybeSuggestion) {\n\t\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Noop\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.LessThanMin\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t )}`;\n\n\t\t\t\tconst maxRule = validation.MoreThanMax\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t )}`;\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\ttry {\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// When we have an error here, it's most probably because the user has a stale SESSION cookie\n\n\t\t\t\t\t\t// Ensure to logout user to remove SESSION and prismic-auth cookies\n\t\t\t\t\t\tawait this.manager.user.logout();\n\n\t\t\t\t\t\t// Force a new login to get a brand new cookies value\n\t\t\t\t\t\ttask.output =\n\t\t\t\t\t\t\t\"It seems there is an authentication problem, press any key to open the browser to login again...\";\n\t\t\t\t\t\tawait this.pressKeyToLogin();\n\t\t\t\t\t\ttask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\n\n\t\t\t\t\t\t// Try to create repository again with the new cookies value\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.output = \"\";\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\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t// title: \"Starting plugin runner...\",\n\t\t\t\t\t\t\ttitle: \"Loading adapter...\",\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// task.title = \"Started plugin runner\";\n\t\t\t\t\t\t\t\ttask.title = \"Loaded adapter\";\n\t\t\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// parentTask.title = `${parentTask.title} and started plugin runner`;\n\t\t\t\t\t\t\t\tparentTask.title = `${parentTask.title} and loaded adapter`;\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 async readAllSlices(): Promise<\n\t\t{ libraryID: string; sliceID: string }[]\n\t> {\n\t\tconst { libraries, errors } =\n\t\t\tawait this.manager.slices.readAllSliceLibraries();\n\n\t\tif (errors.length > 0) {\n\t\t\t// TODO: Provide better error message.\n\t\t\tthrow new Error(`Failed to read slice libraries: ${errors.join(\", \")}`);\n\t\t}\n\n\t\tconst slices: { libraryID: string; sliceID: string }[] = [];\n\t\tfor (const library of libraries) {\n\t\t\tif (library.sliceIDs) {\n\t\t\t\tfor (const sliceID of library.sliceIDs) {\n\t\t\t\t\tslices.push({\n\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\tsliceID,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn slices;\n\t}\n\n\tprotected async readDocuments(): Promise<\n\t\t| {\n\t\t\t\tsignature: string;\n\t\t\t\tdocuments: string[];\n\t\t\t\tdirectoryPath: string;\n\t\t }\n\t\t| undefined\n\t> {\n\t\tconst root = await this.manager.project.getRoot();\n\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\ttry {\n\t\t\tawait fs.access(documentsDirectoryPath);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tconst signaturePath = path.resolve(documentsDirectoryPath, \"index.json\");\n\t\tconst rawSignature = await fs.readFile(signaturePath, \"utf-8\");\n\t\tconst signature: string = JSON.parse(rawSignature).signature;\n\n\t\tconst documents = await globby(\"*/*.json\", {\n\t\t\tcwd: documentsDirectoryPath,\n\t\t});\n\n\t\treturn { signature, documents, directoryPath: documentsDirectoryPath };\n\t}\n\n\tprotected syncDataWithPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Syncing data with 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 slices = await this.readAllSlices();\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\ttask.title = \"Pushing slices... (initializing ACL)\";\n\t\t\t\t\t\t\t\tawait this.manager.screenshots.initS3ACL();\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({\n\t\t\t\t\t\t\t\t\t\t\t...slice,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\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 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 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({\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing 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 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 `syncDataWithPrismic`\",\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 documentsRead = await this.readDocuments();\n\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tdocumentsRead === undefined ||\n\t\t\t\t\t\t\t\t\t\tdocumentsRead.documents.length === 0\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst { signature, documents, directoryPath } = documentsRead;\n\n\t\t\t\t\t\t\t\t\t// TODO: Replace `unknown` with a Prismic document type.\n\t\t\t\t\t\t\t\t\t// The exact format is not know at this time, hence the `unknown`.\n\t\t\t\t\t\t\t\t\tconst recordDocument: Record<string, unknown> = {};\n\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tdocuments.map(async (documentPath) => {\n\t\t\t\t\t\t\t\t\t\t\tconst filename = path.basename(documentPath, \".json\");\n\t\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\t\tpath.resolve(directoryPath, documentPath),\n\t\t\t\t\t\t\t\t\t\t\t\t\"utf-8\",\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\t// TOOD: Validate the contents of the JSON file and skip on invalid documents.\n\t\t\t\t\t\t\t\t\t\t\t\tconst parsedContents = JSON.parse(fileContent);\n\n\t\t\t\t\t\t\t\t\t\t\t\trecordDocument[filename] = parsedContents;\n\t\t\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\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\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`Skipped document due to its invalid format: ${documentPath}`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\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\n\t\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.pushDocuments({\n\t\t\t\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\t\t\t\tdocuments: recordDocument,\n\t\t\t\t\t\t\t\t\t\tsignature,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\ttask.title = \"Pushed all documents\";\n\t\t\t\t\t\t\t\t} catch {\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\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},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pulling existing types...\",\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(\"Types already exist\");\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with Prismic\";\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 remoteTypes =\n\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.fetchRemoteCustomTypes();\n\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tremoteTypes.map(async (model) => {\n\t\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.createCustomType({ model });\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 = \"Pulled existing types\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with 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\t{\n\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t// title: \"Initializing plugins...\",\n\t\t\t\t\ttitle: \"Initializing adapter...\",\n\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\tconst updateOutput = (data: Buffer | string | null) => {\n\t\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t\t} else if (typeof data === \"string\") {\n\t\t\t\t\t\t\t\ttask.output = data;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tawait this.manager.project.initProject({\n\t\t\t\t\t\t\tlog: updateOutput,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t// task.title = \"Initialized plugins\";\n\t\t\t\t\t\ttask.title = \"Initialized adapter\";\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ exitOnError: false },\n\t\t).catch(() => void 0);\n\t}\n}\n"],"names":["updateSentryContext","trackSentryError","createSliceMachineManager","pkg","setupSentry","assertExists","getRunScriptCommand","getExecuteCommand","prompt","execaCommand","listrRun","downloadTemplate","GIGET_PROVIDER","GIGET_ORGANIZATION","fs","getRandomRepositoryDomain","listr","_","detectFramework","detectStarterId","_b","_a","formatRepositoryDomain","validateRepositoryDomainAndAvailability","domain","getErrorMessageForRepositoryDomainValidation","validateRepositoryDomain","path","maybeSuggestion","REPOSITORY_NAME_VALIDATION","globby","SLICE_MACHINE_INIT_USER_AGENT","START_SCRIPT_KEY","START_SCRIPT_VALUE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,kBAAkD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,mBAAmB;;AAGP,MAAA,gCAAgC,CAC5C,YAC4B;AACrB,SAAA,IAAI,wBAAwB,OAAO;AAC3C;MAkBa,wBAAuB;AAAA,EAMnC,YAAY,SAAwC;AAL1C;AACA;AAEA;AAsLA,sCAAa,OAAO,UAAiC;AACxD,YAAA,KAAK,iBAAiB,KAAK;AAC3B,YAAA,KAAK,oBAAoB,KAAK;AAAA,IAAA;AAG3B,+CAAsB,OAAO,UAAiC;;AAEjE,YAAA,aACL,iBAAiB,QAAQ,MAAM,UAAU,GAAG,SAC3C,MAAM,GAAG,GAAG;AACR,YAAA,KAAK,QAAQ,UAAU,MAAM;AAAA,QAClC,OAAO;AAAA,QACP,aA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gC;AACrD,gBAAI,gBAAgB,QAAQ;AACtB,mBAAA,SAAS,KAAK;uBACT,OAAO,SAAS,UAAU;AACpC,mBAAK,SAAS;AAAA,YACd;AAAA,UAAA;AAGI,gBAAA,KAAK,QAAQ,QAAQ,YAAY;AAAA,YACtC,KAAK;AAAA,UAAA,CACL;AAID,eAAK,QAAQ;AAAA,QACd;AAAA,MACA;AAAA,IAAA,GAEF,EAAE,aAAa,MAAO,CAAA,EACrB,MAAM,MAAM,MAAM;AAAA,EACrB;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\";\n\nimport { execaCommand, type ExecaChildProcess } from \"execa\";\n\nimport open from \"open\";\nimport logSymbols from \"log-symbols\";\nimport { globby } from \"globby\";\nimport { downloadTemplate } from \"giget\";\nimport pLimit from \"p-limit\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n\tPackageManager,\n\tStarterId,\n\tREPOSITORY_NAME_VALIDATION,\n} from \"@slicemachine/manager\";\n\nimport pkg from \"../package.json\";\nimport { detectFramework, Framework } from \"./lib/framework\";\nimport { getRunScriptCommand } from \"./lib/getRunScriptCommand\";\nimport { getExecuteCommand } from \"./lib/getExecuteCommand\";\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 {\n\tGIGET_ORGANIZATION,\n\tGIGET_PROVIDER,\n\tSLICE_MACHINE_INIT_USER_AGENT,\n\tSTART_SCRIPT_KEY,\n\tSTART_SCRIPT_VALUE,\n} from \"./constants\";\nimport { detectStarterId } from \"./lib/starters\";\nimport { setupSentry } from \"./lib/setupSentry\";\nimport { trackSentryError } from \"./lib/sentryErrorHandlers\";\nimport { updateSentryContext } from \"./lib/updateSentryContext\";\n\nexport type SliceMachineInitProcessOptions = {\n\trepository?: string;\n\tstarter?: string;\n\tdirectoryName?: string;\n\tpush?: boolean;\n\tpushSlices?: boolean;\n\tpushCustomTypes?: boolean;\n\tpushDocuments?: boolean;\n\tstartSlicemachine?: 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\tstartSlicemachine: 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?: PackageManager;\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\tstarterId?: StarterId;\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)} Initializing\\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.starter) {\n\t\t\t\tawait this.copyStarter();\n\t\t\t} else if (this.options.directoryName) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${logSymbols.warning} --directory-name has no effect because --starter is not specified\\n`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (await this.manager.telemetry.checkIsTelemetryEnabled()) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${\n\t\t\t\t\t\tlogSymbols.info\n\t\t\t\t\t} We collect telemetry data to improve user experience.\\n Learn more: ${chalk.cyan(\n\t\t\t\t\t\t\"https://prismic.dev/slice-machine/telemetry\",\n\t\t\t\t\t)}\\n`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.manager.telemetry.initTelemetry({\n\t\t\t\tappName: pkg.name,\n\t\t\t\tappVersion: pkg.version,\n\t\t\t});\n\t\t\tawait setupSentry();\n\t\t\tawait this.manager.telemetry.track({\n\t\t\t\tevent: \"command:init:start\",\n\t\t\t\trepository: this.options.repository,\n\t\t\t});\n\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\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.loginAndFetchUserData();\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\tawait this.finishCoreDependenciesInstallation();\n\t\t\tawait this.upsertSliceMachineConfigurationAndStartPluginRunner();\n\n\t\t\tconst isLoginRequired = await this.checkIsLoginRequired();\n\t\t\tif (isLoginRequired) {\n\t\t\t\tawait this.loginAndFetchUserData();\n\t\t\t\tif (this.context.repository.exists) {\n\t\t\t\t\tthis.validateWriteAccess();\n\t\t\t\t}\n\t\t\t}\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.syncDataWithPrismic();\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.sliceMachineTelemetryID,\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)} Initialization successful!\n\nContinue with next steps in Slice Machine.\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.startSlicemachine) {\n\t\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t\t })\n\t\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t\t });\n\n\t\t\t\tconst { startSlicemachine } = await prompt<\n\t\t\t\t\tboolean,\n\t\t\t\t\t\"startSlicemachine\"\n\t\t\t\t>({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"startSlicemachine\",\n\t\t\t\t\tmessage: `Run Slice Machine (${chalk.cyan(runSmCommand)})?`,\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (startSlicemachine) {\n\t\t\t\t\tconst commandReturnValue = await execaCommand(runSmCommand, {\n\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t}).pipeStdout?.(process.stdout);\n\t\t\t\t\tif (commandReturnValue !== undefined) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.log(commandReturnValue.stdout);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Only track this error with Sentry, it's only the final convenience message\n\t\t\tawait this.trackSentryError(error);\n\t\t}\n\t}\n\n\tprotected async checkIsLoginRequired(): Promise<boolean> {\n\t\ttry {\n\t\t\tassertExists(this.context.repository, \"\");\n\t\t\tif (this.context.repository.exists === false) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst [slices, ctLibrary, documentsGlob] = await Promise.all([\n\t\t\t\tthis.readAllSlices(),\n\t\t\t\tthis.manager.customTypes.readCustomTypeLibrary(),\n\t\t\t\tthis.readDocuments(),\n\t\t\t]);\n\n\t\t\t// If repository exists, and there's anything to push\n\t\t\tif (\n\t\t\t\tslices.length > 0 ||\n\t\t\t\tctLibrary.ids.length > 0 ||\n\t\t\t\t(documentsGlob !== undefined && documentsGlob.documents.length > 0)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// If repository exists, and there might be things to pull\n\t\t\tif (ctLibrary.ids.length === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected trackError = async (error: unknown): Promise<void> => {\n\t\tawait this.trackSentryError(error);\n\t\tawait this.trackTelemetryError(error);\n\t};\n\n\tprotected trackTelemetryError = async (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\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"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 trackSentryError = async (error: unknown): Promise<void> => {\n\t\tawait updateSentryContext({\n\t\t\tmanager: this.manager,\n\t\t\trepositoryName: this.context.repository?.domain || \"\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"unknown\",\n\t\t});\n\t\ttrackSentryError(error);\n\t};\n\n\tprotected async copyStarter(): Promise<void> {\n\t\tconst dir = await this.getStarterDirectoryName();\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Copying starter...\\n\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tconst starter = this.options.starter;\n\n\t\t\t\t\tawait downloadTemplate(\n\t\t\t\t\t\t`${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tprocess.chdir(dir);\n\t\t\t\t\tthis.manager.cwd = process.cwd();\n\n\t\t\t\t\ttask.title = \"Starter copied\\n\";\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected async getStarterDirectoryName(): Promise<string> {\n\t\tlet directoryName: string;\n\t\tconst folderNames = await fs.readdir(process.cwd());\n\n\t\tif (\n\t\t\tthis.options.directoryName &&\n\t\t\t!folderNames.includes(this.options.directoryName)\n\t\t) {\n\t\t\t// Use provided directory\n\t\t\tdirectoryName = this.options.directoryName;\n\t\t} else if (\n\t\t\tthis.options.repository &&\n\t\t\t!folderNames.includes(this.options.repository)\n\t\t) {\n\t\t\t// Use repository name\n\t\t\tdirectoryName = this.options.repository;\n\t\t} else {\n\t\t\t// Use random name\n\t\t\tlet suggestedName: string;\n\t\t\tdo {\n\t\t\t\tsuggestedName = getRandomRepositoryDomain();\n\t\t\t} while (folderNames.includes(suggestedName));\n\n\t\t\tconst { selectedDirectory } = await prompt<string, \"selectedDirectory\">({\n\t\t\t\ttype: \"text\",\n\t\t\t\tname: \"selectedDirectory\",\n\t\t\t\tmessage: \"Your starter directory name\",\n\t\t\t\tinitial: suggestedName,\n\t\t\t\tvalidate: async (rawDirectory: string) => {\n\t\t\t\t\tif (folderNames.includes(rawDirectory)) {\n\t\t\t\t\t\treturn \"Directory name already exists\";\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tdirectoryName = selectedDirectory;\n\t\t}\n\n\t\treturn directoryName;\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 =\n\t\t\t\t\t\t\t\t\tawait this.manager.project.detectPackageManager({\n\t\t\t\t\t\t\t\t\t\troot: this.manager.cwd,\n\t\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\t{\n\t\t\t\t\t\t\ttitle: \"Detecting starter...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.starterId = await detectStarterId(\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\tif (this.context.starterId) {\n\t\t\t\t\t\t\t\t\ttask.title = `Detected starter ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\tthis.context.starterId,\n\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\ttask.title = \"No starter detected\";\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 } =\n\t\t\t\t\t\tawait this.manager.project.installDependencies({\n\t\t\t\t\t\t\tpackageManager: this.context.packageManager,\n\t\t\t\t\t\t\tdependencies: this.context.framework.devDependencies,\n\t\t\t\t\t\t\tdev: true,\n\t\t\t\t\t\t\t// Picked up later\n\t\t\t\t\t\t\tlog: () => {\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\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);\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 async fetchUserProfile(): Promise<void> {\n\t\tthis.context.userProfile = await this.manager.user.getProfile();\n\n\t\tawait this.manager.telemetry.identify({\n\t\t\tuserID: this.context.userProfile.shortId,\n\t\t\tintercomHash: this.context.userProfile.intercomHash,\n\t\t});\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:identify\",\n\t\t\trepository: this.options.repository,\n\t\t});\n\t}\n\n\tprotected async fetchUserRepositories(): Promise<void> {\n\t\tthis.context.userRepositories =\n\t\t\tawait this.manager.prismicRepository.readAll();\n\t}\n\n\tprotected validateWriteAccess(): void {\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\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to validate write access\",\n\t\t);\n\t\tconst { domain } = this.context.repository;\n\t\tconst maybeRepository = this.context.userRepositories.find(\n\t\t\t(repository) => repository.domain === domain,\n\t\t);\n\n\t\tif (maybeRepository) {\n\t\t\tif (!this.manager.prismicRepository.hasWriteAccess(maybeRepository)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot run init command with repository ${chalk.cyan(\n\t\t\t\t\t\tmaybeRepository.domain,\n\t\t\t\t\t)}: you are not a developer or admin of this repository`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot validate write access for repository ${chalk.cyan(\n\t\t\t\t\tdomain,\n\t\t\t\t)}: you are not part of this repository`,\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 this.pressKeyToLogin();\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\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\tawait this.fetchUserProfile();\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\tawait this.fetchUserRepositories();\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 async pressKeyToLogin(): Promise<void> {\n\t\tawait new Promise((resolve) => {\n\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\tprocess.stdin.resume();\n\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\tprocess.stdin.pause();\n\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t});\n\t\t});\n\t}\n\n\tprotected async waitingForLogin(): Promise<void> {\n\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\tawait this.manager.user.nodeLoginSession({\n\t\t\tport,\n\t\t\tonListenCallback() {\n\t\t\t\topen(url);\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.options.repository,\n\t\t\t\t\t\t\"Flag `repository` must be set to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\t\t\t\t\tconst domain = formatRepositoryDomain(this.options.repository);\n\t\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t\t});\n\n\t\t\t\t\tif (validation.LessThanMin || validation.MoreThanMax) {\n\t\t\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\t\t\tvalidation: {\n\t\t\t\t\t\t\t\t...validation,\n\t\t\t\t\t\t\t\t// We don't want to throw if repo already exists.\n\t\t\t\t\t\t\t\t// User most probably just created it via their dashboard.\n\t\t\t\t\t\t\t\tAlreadyExists: false,\n\t\t\t\t\t\t\t},\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: validation.AlreadyExists ?? false,\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 directory name\n\t\tconst maybeSuggestion = await trySuggestName(\n\t\t\tpath.basename(this.manager.cwd),\n\t\t);\n\t\tif (maybeSuggestion) {\n\t\t\tsuggestedName = maybeSuggestion;\n\t\t}\n\n\t\t// 2. Try to suggest name after package name\n\t\tif (!suggestedName) {\n\t\t\ttry {\n\t\t\t\tconst pkgJSONPath = path.join(this.manager.cwd, \"package.json\");\n\t\t\t\tconst pkg = JSON.parse(await fs.readFile(pkgJSONPath, \"utf-8\"));\n\n\t\t\t\tconst maybeSuggestion = await trySuggestName(pkg.name);\n\t\t\t\tif (maybeSuggestion) {\n\t\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Noop\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.LessThanMin\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t )}`;\n\n\t\t\t\tconst maxRule = validation.MoreThanMax\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t )}`;\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\ttry {\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// When we have an error here, it's most probably because the user has a stale SESSION cookie\n\n\t\t\t\t\t\t// Ensure to logout user to remove SESSION and prismic-auth cookies\n\t\t\t\t\t\tawait this.manager.user.logout();\n\n\t\t\t\t\t\t// Force a new login to get a brand new cookies value\n\t\t\t\t\t\ttask.output =\n\t\t\t\t\t\t\t\"It seems there is an authentication problem, press any key to open the browser to login again...\";\n\t\t\t\t\t\tawait this.pressKeyToLogin();\n\t\t\t\t\t\ttask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\n\n\t\t\t\t\t\t// Try to create repository again with the new cookies value\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.output = \"\";\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\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t// title: \"Starting plugin runner...\",\n\t\t\t\t\t\t\ttitle: \"Loading adapter...\",\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// task.title = \"Started plugin runner\";\n\t\t\t\t\t\t\t\ttask.title = \"Loaded adapter\";\n\t\t\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// parentTask.title = `${parentTask.title} and started plugin runner`;\n\t\t\t\t\t\t\t\tparentTask.title = `${parentTask.title} and loaded adapter`;\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 async readAllSlices(): Promise<\n\t\t{ libraryID: string; sliceID: string }[]\n\t> {\n\t\tconst { libraries, errors } =\n\t\t\tawait this.manager.slices.readAllSliceLibraries();\n\n\t\tif (errors.length > 0) {\n\t\t\t// TODO: Provide better error message.\n\t\t\tthrow new Error(`Failed to read slice libraries: ${errors.join(\", \")}`);\n\t\t}\n\n\t\tconst slices: { libraryID: string; sliceID: string }[] = [];\n\t\tfor (const library of libraries) {\n\t\t\tif (library.sliceIDs) {\n\t\t\t\tfor (const sliceID of library.sliceIDs) {\n\t\t\t\t\tslices.push({\n\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\tsliceID,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn slices;\n\t}\n\n\tprotected async readDocuments(): Promise<\n\t\t| {\n\t\t\t\tsignature: string;\n\t\t\t\tdocuments: string[];\n\t\t\t\tdirectoryPath: string;\n\t\t }\n\t\t| undefined\n\t> {\n\t\tconst root = await this.manager.project.getRoot();\n\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\ttry {\n\t\t\tawait fs.access(documentsDirectoryPath);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tconst signaturePath = path.resolve(documentsDirectoryPath, \"index.json\");\n\t\tconst rawSignature = await fs.readFile(signaturePath, \"utf-8\");\n\t\tconst signature: string = JSON.parse(rawSignature).signature;\n\n\t\tconst documents = await globby(\"*/*.json\", {\n\t\t\tcwd: documentsDirectoryPath,\n\t\t});\n\n\t\treturn { signature, documents, directoryPath: documentsDirectoryPath };\n\t}\n\n\tprotected syncDataWithPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Syncing data with 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 slices = await this.readAllSlices();\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\ttask.title = \"Pushing slices... (initializing ACL)\";\n\t\t\t\t\t\t\t\tawait this.manager.screenshots.initS3ACL();\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({\n\t\t\t\t\t\t\t\t\t\t\t...slice,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\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 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 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({\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing 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 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 `syncDataWithPrismic`\",\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 documentsRead = await this.readDocuments();\n\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tdocumentsRead === undefined ||\n\t\t\t\t\t\t\t\t\t\tdocumentsRead.documents.length === 0\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst { signature, documents, directoryPath } = documentsRead;\n\n\t\t\t\t\t\t\t\t\t// TODO: Replace `unknown` with a Prismic document type.\n\t\t\t\t\t\t\t\t\t// The exact format is not know at this time, hence the `unknown`.\n\t\t\t\t\t\t\t\t\tconst recordDocument: Record<string, unknown> = {};\n\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tdocuments.map(async (documentPath) => {\n\t\t\t\t\t\t\t\t\t\t\tconst filename = path.basename(documentPath, \".json\");\n\t\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\t\tpath.resolve(directoryPath, documentPath),\n\t\t\t\t\t\t\t\t\t\t\t\t\"utf-8\",\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\t// TOOD: Validate the contents of the JSON file and skip on invalid documents.\n\t\t\t\t\t\t\t\t\t\t\t\tconst parsedContents = JSON.parse(fileContent);\n\n\t\t\t\t\t\t\t\t\t\t\t\trecordDocument[filename] = parsedContents;\n\t\t\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\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\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`Skipped document due to its invalid format: ${documentPath}`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\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\n\t\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.pushDocuments({\n\t\t\t\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\t\t\t\tdocuments: recordDocument,\n\t\t\t\t\t\t\t\t\t\tsignature,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\ttask.title = \"Pushed all documents\";\n\t\t\t\t\t\t\t\t} catch {\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\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},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pulling existing types...\",\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(\"Types already exist\");\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with Prismic\";\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 remoteTypes =\n\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.fetchRemoteCustomTypes();\n\n\t\t\t\t\t\t\t\tconst createCustomTypeLimit = pLimit(8);\n\n\t\t\t\t\t\t\t\tlet pulled = 0;\n\t\t\t\t\t\t\t\ttask.title = `Pulling existing types... (0/${remoteTypes.length})`;\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tremoteTypes.map(async (model) => {\n\t\t\t\t\t\t\t\t\t\tawait createCustomTypeLimit(() =>\n\t\t\t\t\t\t\t\t\t\t\tthis.manager.customTypes.createCustomType({ model }),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tpulled++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pulling existing types... (${pulled}/${remoteTypes.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 = \"Pulled existing types\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with 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\t{\n\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t// title: \"Initializing plugins...\",\n\t\t\t\t\ttitle: \"Initializing adapter...\",\n\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\tconst updateOutput = (data: Buffer | string | null) => {\n\t\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t\t} else if (typeof data === \"string\") {\n\t\t\t\t\t\t\t\ttask.output = data;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tawait this.manager.project.initProject({\n\t\t\t\t\t\t\tlog: updateOutput,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t// task.title = \"Initialized plugins\";\n\t\t\t\t\t\ttask.title = \"Initialized adapter\";\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ exitOnError: false },\n\t\t).catch(() => void 0);\n\t}\n}\n"],"names":["updateSentryContext","trackSentryError","createSliceMachineManager","pkg","setupSentry","assertExists","getRunScriptCommand","getExecuteCommand","prompt","execaCommand","listrRun","downloadTemplate","GIGET_PROVIDER","GIGET_ORGANIZATION","fs","getRandomRepositoryDomain","listr","_","detectFramework","detectStarterId","_b","_a","formatRepositoryDomain","validateRepositoryDomainAndAvailability","domain","getErrorMessageForRepositoryDomainValidation","validateRepositoryDomain","path","maybeSuggestion","REPOSITORY_NAME_VALIDATION","globby","SLICE_MACHINE_INIT_USER_AGENT","pLimit","START_SCRIPT_KEY","START_SCRIPT_VALUE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,kBAAkD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,mBAAmB;;AAGP,MAAA,gCAAgC,CAC5C,YAC4B;AACrB,SAAA,IAAI,wBAAwB,OAAO;AAC3C;MAkBa,wBAAuB;AAAA,EAMnC,YAAY,SAAwC;AAL1C;AACA;AAEA;AAsLA,sCAAa,OAAO,UAAiC;AACxD,YAAA,KAAK,iBAAiB,KAAK;AAC3B,YAAA,KAAK,oBAAoB,KAAK;AAAA,IAAA;AAG3B,+CAAsB,OAAO,UAAiC;;AAEjE,YAAA,aACL,iBAAiB,QAAQ,MAAM,UAAU,GAAG,SAC3C,MAAM,GAAG,GAAG;AACR,YAAA,KAAK,QAAQ,UAAU,MAAM;AAAA,QAClC,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A,MACF;AAAA,IAAA,CACD;AAAA,EACF;AAAA,EAEU,oBAAiB;AAC1B,WAAOxB,eACN;AAAA,MACC;AAAA;AAAA;AAAA,QAGC,OAAO;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;AAGI,gBAAA,KAAK,QAAQ,QAAQ,YAAY;AAAA,YACtC,KAAK;AAAA,UAAA,CACL;AAID,eAAK,QAAQ;AAAA,QACd;AAAA,MACA;AAAA,IAAA,GAEF,EAAE,aAAa,MAAO,CAAA,EACrB,MAAM,MAAM,MAAM;AAAA,EACrB;AACA;;;"}
|
|
@@ -12,6 +12,7 @@ import open from "open";
|
|
|
12
12
|
import logSymbols from "log-symbols";
|
|
13
13
|
import { globby } from './_node_modules/globby/index.js';
|
|
14
14
|
import { downloadTemplate } from "giget";
|
|
15
|
+
import pLimit from './_node_modules/p-limit/index.js';
|
|
15
16
|
import { createSliceMachineManager, REPOSITORY_NAME_VALIDATION } from "@slicemachine/manager";
|
|
16
17
|
import pkg from "./packages/init/package.json.js";
|
|
17
18
|
import { detectFramework } from "./lib/framework.js";
|
|
@@ -132,7 +133,7 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
|
|
|
132
133
|
});
|
|
133
134
|
console.log(`
|
|
134
135
|
${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} Initialization successful!
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
Continue with next steps in Slice Machine.
|
|
137
138
|
`);
|
|
138
139
|
try {
|
|
@@ -839,8 +840,13 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
|
|
|
839
840
|
return;
|
|
840
841
|
}
|
|
841
842
|
const remoteTypes = await this.manager.customTypes.fetchRemoteCustomTypes();
|
|
843
|
+
const createCustomTypeLimit = pLimit(8);
|
|
844
|
+
let pulled = 0;
|
|
845
|
+
task.title = `Pulling existing types... (0/${remoteTypes.length})`;
|
|
842
846
|
await Promise.all(remoteTypes.map(async (model) => {
|
|
843
|
-
await this.manager.customTypes.createCustomType({ model });
|
|
847
|
+
await createCustomTypeLimit(() => this.manager.customTypes.createCustomType({ model }));
|
|
848
|
+
pulled++;
|
|
849
|
+
task.title = `Pulling existing types... (${pulled}/${remoteTypes.length})`;
|
|
844
850
|
}));
|
|
845
851
|
task.title = "Pulled existing types";
|
|
846
852
|
parentTask.title = "Synced data with Prismic";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceMachineInitProcess.js","sources":["../../src/SliceMachineInitProcess.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport chalk from \"chalk\";\n\nimport { execaCommand, type ExecaChildProcess } from \"execa\";\n\nimport open from \"open\";\nimport logSymbols from \"log-symbols\";\nimport { globby } from \"globby\";\nimport { downloadTemplate } from \"giget\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n\tPackageManager,\n\tStarterId,\n\tREPOSITORY_NAME_VALIDATION,\n} from \"@slicemachine/manager\";\n\nimport pkg from \"../package.json\";\nimport { detectFramework, Framework } from \"./lib/framework\";\nimport { getRunScriptCommand } from \"./lib/getRunScriptCommand\";\nimport { getExecuteCommand } from \"./lib/getExecuteCommand\";\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 {\n\tGIGET_ORGANIZATION,\n\tGIGET_PROVIDER,\n\tSLICE_MACHINE_INIT_USER_AGENT,\n\tSTART_SCRIPT_KEY,\n\tSTART_SCRIPT_VALUE,\n} from \"./constants\";\nimport { detectStarterId } from \"./lib/starters\";\nimport { setupSentry } from \"./lib/setupSentry\";\nimport { trackSentryError } from \"./lib/sentryErrorHandlers\";\nimport { updateSentryContext } from \"./lib/updateSentryContext\";\n\nexport type SliceMachineInitProcessOptions = {\n\trepository?: string;\n\tstarter?: string;\n\tdirectoryName?: string;\n\tpush?: boolean;\n\tpushSlices?: boolean;\n\tpushCustomTypes?: boolean;\n\tpushDocuments?: boolean;\n\tstartSlicemachine?: 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\tstartSlicemachine: 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?: PackageManager;\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\tstarterId?: StarterId;\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)} Initializing\\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.starter) {\n\t\t\t\tawait this.copyStarter();\n\t\t\t} else if (this.options.directoryName) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${logSymbols.warning} --directory-name has no effect because --starter is not specified\\n`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (await this.manager.telemetry.checkIsTelemetryEnabled()) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${\n\t\t\t\t\t\tlogSymbols.info\n\t\t\t\t\t} We collect telemetry data to improve user experience.\\n Learn more: ${chalk.cyan(\n\t\t\t\t\t\t\"https://prismic.dev/slice-machine/telemetry\",\n\t\t\t\t\t)}\\n`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.manager.telemetry.initTelemetry({\n\t\t\t\tappName: pkg.name,\n\t\t\t\tappVersion: pkg.version,\n\t\t\t});\n\t\t\tawait setupSentry();\n\t\t\tawait this.manager.telemetry.track({\n\t\t\t\tevent: \"command:init:start\",\n\t\t\t\trepository: this.options.repository,\n\t\t\t});\n\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\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.loginAndFetchUserData();\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\tawait this.finishCoreDependenciesInstallation();\n\t\t\tawait this.upsertSliceMachineConfigurationAndStartPluginRunner();\n\n\t\t\tconst isLoginRequired = await this.checkIsLoginRequired();\n\t\t\tif (isLoginRequired) {\n\t\t\t\tawait this.loginAndFetchUserData();\n\t\t\t\tif (this.context.repository.exists) {\n\t\t\t\t\tthis.validateWriteAccess();\n\t\t\t\t}\n\t\t\t}\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.syncDataWithPrismic();\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.sliceMachineTelemetryID,\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)} Initialization successful!\n\t\t\t\nContinue with next steps in Slice Machine.\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.startSlicemachine) {\n\t\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t\t })\n\t\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t\t });\n\n\t\t\t\tconst { startSlicemachine } = await prompt<\n\t\t\t\t\tboolean,\n\t\t\t\t\t\"startSlicemachine\"\n\t\t\t\t>({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"startSlicemachine\",\n\t\t\t\t\tmessage: `Run Slice Machine (${chalk.cyan(runSmCommand)})?`,\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (startSlicemachine) {\n\t\t\t\t\tconst commandReturnValue = await execaCommand(runSmCommand, {\n\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t}).pipeStdout?.(process.stdout);\n\t\t\t\t\tif (commandReturnValue !== undefined) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.log(commandReturnValue.stdout);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Only track this error with Sentry, it's only the final convenience message\n\t\t\tawait this.trackSentryError(error);\n\t\t}\n\t}\n\n\tprotected async checkIsLoginRequired(): Promise<boolean> {\n\t\ttry {\n\t\t\tassertExists(this.context.repository, \"\");\n\t\t\tif (this.context.repository.exists === false) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst [slices, ctLibrary, documentsGlob] = await Promise.all([\n\t\t\t\tthis.readAllSlices(),\n\t\t\t\tthis.manager.customTypes.readCustomTypeLibrary(),\n\t\t\t\tthis.readDocuments(),\n\t\t\t]);\n\n\t\t\t// If repository exists, and there's anything to push\n\t\t\tif (\n\t\t\t\tslices.length > 0 ||\n\t\t\t\tctLibrary.ids.length > 0 ||\n\t\t\t\t(documentsGlob !== undefined && documentsGlob.documents.length > 0)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// If repository exists, and there might be things to pull\n\t\t\tif (ctLibrary.ids.length === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected trackError = async (error: unknown): Promise<void> => {\n\t\tawait this.trackSentryError(error);\n\t\tawait this.trackTelemetryError(error);\n\t};\n\n\tprotected trackTelemetryError = async (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\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"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 trackSentryError = async (error: unknown): Promise<void> => {\n\t\tawait updateSentryContext({\n\t\t\tmanager: this.manager,\n\t\t\trepositoryName: this.context.repository?.domain || \"\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"unknown\",\n\t\t});\n\t\ttrackSentryError(error);\n\t};\n\n\tprotected async copyStarter(): Promise<void> {\n\t\tconst dir = await this.getStarterDirectoryName();\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Copying starter...\\n\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tconst starter = this.options.starter;\n\n\t\t\t\t\tawait downloadTemplate(\n\t\t\t\t\t\t`${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tprocess.chdir(dir);\n\t\t\t\t\tthis.manager.cwd = process.cwd();\n\n\t\t\t\t\ttask.title = \"Starter copied\\n\";\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected async getStarterDirectoryName(): Promise<string> {\n\t\tlet directoryName: string;\n\t\tconst folderNames = await fs.readdir(process.cwd());\n\n\t\tif (\n\t\t\tthis.options.directoryName &&\n\t\t\t!folderNames.includes(this.options.directoryName)\n\t\t) {\n\t\t\t// Use provided directory\n\t\t\tdirectoryName = this.options.directoryName;\n\t\t} else if (\n\t\t\tthis.options.repository &&\n\t\t\t!folderNames.includes(this.options.repository)\n\t\t) {\n\t\t\t// Use repository name\n\t\t\tdirectoryName = this.options.repository;\n\t\t} else {\n\t\t\t// Use random name\n\t\t\tlet suggestedName: string;\n\t\t\tdo {\n\t\t\t\tsuggestedName = getRandomRepositoryDomain();\n\t\t\t} while (folderNames.includes(suggestedName));\n\n\t\t\tconst { selectedDirectory } = await prompt<string, \"selectedDirectory\">({\n\t\t\t\ttype: \"text\",\n\t\t\t\tname: \"selectedDirectory\",\n\t\t\t\tmessage: \"Your starter directory name\",\n\t\t\t\tinitial: suggestedName,\n\t\t\t\tvalidate: async (rawDirectory: string) => {\n\t\t\t\t\tif (folderNames.includes(rawDirectory)) {\n\t\t\t\t\t\treturn \"Directory name already exists\";\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tdirectoryName = selectedDirectory;\n\t\t}\n\n\t\treturn directoryName;\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 =\n\t\t\t\t\t\t\t\t\tawait this.manager.project.detectPackageManager({\n\t\t\t\t\t\t\t\t\t\troot: this.manager.cwd,\n\t\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\t{\n\t\t\t\t\t\t\ttitle: \"Detecting starter...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.starterId = await detectStarterId(\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\tif (this.context.starterId) {\n\t\t\t\t\t\t\t\t\ttask.title = `Detected starter ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\tthis.context.starterId,\n\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\ttask.title = \"No starter detected\";\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 } =\n\t\t\t\t\t\tawait this.manager.project.installDependencies({\n\t\t\t\t\t\t\tpackageManager: this.context.packageManager,\n\t\t\t\t\t\t\tdependencies: this.context.framework.devDependencies,\n\t\t\t\t\t\t\tdev: true,\n\t\t\t\t\t\t\t// Picked up later\n\t\t\t\t\t\t\tlog: () => {\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\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);\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 async fetchUserProfile(): Promise<void> {\n\t\tthis.context.userProfile = await this.manager.user.getProfile();\n\n\t\tawait this.manager.telemetry.identify({\n\t\t\tuserID: this.context.userProfile.shortId,\n\t\t\tintercomHash: this.context.userProfile.intercomHash,\n\t\t});\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:identify\",\n\t\t\trepository: this.options.repository,\n\t\t});\n\t}\n\n\tprotected async fetchUserRepositories(): Promise<void> {\n\t\tthis.context.userRepositories =\n\t\t\tawait this.manager.prismicRepository.readAll();\n\t}\n\n\tprotected validateWriteAccess(): void {\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\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to validate write access\",\n\t\t);\n\t\tconst { domain } = this.context.repository;\n\t\tconst maybeRepository = this.context.userRepositories.find(\n\t\t\t(repository) => repository.domain === domain,\n\t\t);\n\n\t\tif (maybeRepository) {\n\t\t\tif (!this.manager.prismicRepository.hasWriteAccess(maybeRepository)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot run init command with repository ${chalk.cyan(\n\t\t\t\t\t\tmaybeRepository.domain,\n\t\t\t\t\t)}: you are not a developer or admin of this repository`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot validate write access for repository ${chalk.cyan(\n\t\t\t\t\tdomain,\n\t\t\t\t)}: you are not part of this repository`,\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 this.pressKeyToLogin();\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\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\tawait this.fetchUserProfile();\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\tawait this.fetchUserRepositories();\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 async pressKeyToLogin(): Promise<void> {\n\t\tawait new Promise((resolve) => {\n\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\tprocess.stdin.resume();\n\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\tprocess.stdin.pause();\n\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t});\n\t\t});\n\t}\n\n\tprotected async waitingForLogin(): Promise<void> {\n\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\tawait this.manager.user.nodeLoginSession({\n\t\t\tport,\n\t\t\tonListenCallback() {\n\t\t\t\topen(url);\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.options.repository,\n\t\t\t\t\t\t\"Flag `repository` must be set to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\t\t\t\t\tconst domain = formatRepositoryDomain(this.options.repository);\n\t\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t\t});\n\n\t\t\t\t\tif (validation.LessThanMin || validation.MoreThanMax) {\n\t\t\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\t\t\tvalidation: {\n\t\t\t\t\t\t\t\t...validation,\n\t\t\t\t\t\t\t\t// We don't want to throw if repo already exists.\n\t\t\t\t\t\t\t\t// User most probably just created it via their dashboard.\n\t\t\t\t\t\t\t\tAlreadyExists: false,\n\t\t\t\t\t\t\t},\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: validation.AlreadyExists ?? false,\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 directory name\n\t\tconst maybeSuggestion = await trySuggestName(\n\t\t\tpath.basename(this.manager.cwd),\n\t\t);\n\t\tif (maybeSuggestion) {\n\t\t\tsuggestedName = maybeSuggestion;\n\t\t}\n\n\t\t// 2. Try to suggest name after package name\n\t\tif (!suggestedName) {\n\t\t\ttry {\n\t\t\t\tconst pkgJSONPath = path.join(this.manager.cwd, \"package.json\");\n\t\t\t\tconst pkg = JSON.parse(await fs.readFile(pkgJSONPath, \"utf-8\"));\n\n\t\t\t\tconst maybeSuggestion = await trySuggestName(pkg.name);\n\t\t\t\tif (maybeSuggestion) {\n\t\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Noop\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.LessThanMin\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t )}`;\n\n\t\t\t\tconst maxRule = validation.MoreThanMax\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t )}`;\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\ttry {\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// When we have an error here, it's most probably because the user has a stale SESSION cookie\n\n\t\t\t\t\t\t// Ensure to logout user to remove SESSION and prismic-auth cookies\n\t\t\t\t\t\tawait this.manager.user.logout();\n\n\t\t\t\t\t\t// Force a new login to get a brand new cookies value\n\t\t\t\t\t\ttask.output =\n\t\t\t\t\t\t\t\"It seems there is an authentication problem, press any key to open the browser to login again...\";\n\t\t\t\t\t\tawait this.pressKeyToLogin();\n\t\t\t\t\t\ttask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\n\n\t\t\t\t\t\t// Try to create repository again with the new cookies value\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.output = \"\";\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\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t// title: \"Starting plugin runner...\",\n\t\t\t\t\t\t\ttitle: \"Loading adapter...\",\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// task.title = \"Started plugin runner\";\n\t\t\t\t\t\t\t\ttask.title = \"Loaded adapter\";\n\t\t\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// parentTask.title = `${parentTask.title} and started plugin runner`;\n\t\t\t\t\t\t\t\tparentTask.title = `${parentTask.title} and loaded adapter`;\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 async readAllSlices(): Promise<\n\t\t{ libraryID: string; sliceID: string }[]\n\t> {\n\t\tconst { libraries, errors } =\n\t\t\tawait this.manager.slices.readAllSliceLibraries();\n\n\t\tif (errors.length > 0) {\n\t\t\t// TODO: Provide better error message.\n\t\t\tthrow new Error(`Failed to read slice libraries: ${errors.join(\", \")}`);\n\t\t}\n\n\t\tconst slices: { libraryID: string; sliceID: string }[] = [];\n\t\tfor (const library of libraries) {\n\t\t\tif (library.sliceIDs) {\n\t\t\t\tfor (const sliceID of library.sliceIDs) {\n\t\t\t\t\tslices.push({\n\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\tsliceID,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn slices;\n\t}\n\n\tprotected async readDocuments(): Promise<\n\t\t| {\n\t\t\t\tsignature: string;\n\t\t\t\tdocuments: string[];\n\t\t\t\tdirectoryPath: string;\n\t\t }\n\t\t| undefined\n\t> {\n\t\tconst root = await this.manager.project.getRoot();\n\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\ttry {\n\t\t\tawait fs.access(documentsDirectoryPath);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tconst signaturePath = path.resolve(documentsDirectoryPath, \"index.json\");\n\t\tconst rawSignature = await fs.readFile(signaturePath, \"utf-8\");\n\t\tconst signature: string = JSON.parse(rawSignature).signature;\n\n\t\tconst documents = await globby(\"*/*.json\", {\n\t\t\tcwd: documentsDirectoryPath,\n\t\t});\n\n\t\treturn { signature, documents, directoryPath: documentsDirectoryPath };\n\t}\n\n\tprotected syncDataWithPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Syncing data with 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 slices = await this.readAllSlices();\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\ttask.title = \"Pushing slices... (initializing ACL)\";\n\t\t\t\t\t\t\t\tawait this.manager.screenshots.initS3ACL();\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({\n\t\t\t\t\t\t\t\t\t\t\t...slice,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\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 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 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({\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing 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 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 `syncDataWithPrismic`\",\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 documentsRead = await this.readDocuments();\n\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tdocumentsRead === undefined ||\n\t\t\t\t\t\t\t\t\t\tdocumentsRead.documents.length === 0\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst { signature, documents, directoryPath } = documentsRead;\n\n\t\t\t\t\t\t\t\t\t// TODO: Replace `unknown` with a Prismic document type.\n\t\t\t\t\t\t\t\t\t// The exact format is not know at this time, hence the `unknown`.\n\t\t\t\t\t\t\t\t\tconst recordDocument: Record<string, unknown> = {};\n\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tdocuments.map(async (documentPath) => {\n\t\t\t\t\t\t\t\t\t\t\tconst filename = path.basename(documentPath, \".json\");\n\t\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\t\tpath.resolve(directoryPath, documentPath),\n\t\t\t\t\t\t\t\t\t\t\t\t\"utf-8\",\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\t// TOOD: Validate the contents of the JSON file and skip on invalid documents.\n\t\t\t\t\t\t\t\t\t\t\t\tconst parsedContents = JSON.parse(fileContent);\n\n\t\t\t\t\t\t\t\t\t\t\t\trecordDocument[filename] = parsedContents;\n\t\t\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\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\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`Skipped document due to its invalid format: ${documentPath}`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\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\n\t\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.pushDocuments({\n\t\t\t\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\t\t\t\tdocuments: recordDocument,\n\t\t\t\t\t\t\t\t\t\tsignature,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\ttask.title = \"Pushed all documents\";\n\t\t\t\t\t\t\t\t} catch {\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\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},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pulling existing types...\",\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(\"Types already exist\");\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with Prismic\";\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 remoteTypes =\n\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.fetchRemoteCustomTypes();\n\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tremoteTypes.map(async (model) => {\n\t\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.createCustomType({ model });\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 = \"Pulled existing types\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with 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\t{\n\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t// title: \"Initializing plugins...\",\n\t\t\t\t\ttitle: \"Initializing adapter...\",\n\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\tconst updateOutput = (data: Buffer | string | null) => {\n\t\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t\t} else if (typeof data === \"string\") {\n\t\t\t\t\t\t\t\ttask.output = data;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tawait this.manager.project.initProject({\n\t\t\t\t\t\t\tlog: updateOutput,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t// task.title = \"Initialized plugins\";\n\t\t\t\t\t\ttask.title = \"Initialized adapter\";\n\t\t\t\t\t},\n\t\t\t\t},\n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,cAEhB;AAAA,YACA;AAAA,UAAA,CACD;AAAA;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACF;AAAA,EAEU,oBAAiB;AAC1B,WAAO,SACN;AAAA,MACC;AAAA;AAAA;AAAA,QAGC,OAAO;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;AAGI,gBAAA,KAAK,QAAQ,QAAQ,YAAY;AAAA,YACtC,KAAK;AAAA,UAAA,CACL;AAID,eAAK,QAAQ;AAAA,QACd;AAAA,MACA;AAAA,IAAA,GAEF,EAAE,aAAa,MAAO,CAAA,EACrB,MAAM,MAAM,MAAM;AAAA,EACrB;AACA;"}
|
|
1
|
+
{"version":3,"file":"SliceMachineInitProcess.js","sources":["../../src/SliceMachineInitProcess.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport chalk from \"chalk\";\n\nimport { execaCommand, type ExecaChildProcess } from \"execa\";\n\nimport open from \"open\";\nimport logSymbols from \"log-symbols\";\nimport { globby } from \"globby\";\nimport { downloadTemplate } from \"giget\";\nimport pLimit from \"p-limit\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n\tPackageManager,\n\tStarterId,\n\tREPOSITORY_NAME_VALIDATION,\n} from \"@slicemachine/manager\";\n\nimport pkg from \"../package.json\";\nimport { detectFramework, Framework } from \"./lib/framework\";\nimport { getRunScriptCommand } from \"./lib/getRunScriptCommand\";\nimport { getExecuteCommand } from \"./lib/getExecuteCommand\";\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 {\n\tGIGET_ORGANIZATION,\n\tGIGET_PROVIDER,\n\tSLICE_MACHINE_INIT_USER_AGENT,\n\tSTART_SCRIPT_KEY,\n\tSTART_SCRIPT_VALUE,\n} from \"./constants\";\nimport { detectStarterId } from \"./lib/starters\";\nimport { setupSentry } from \"./lib/setupSentry\";\nimport { trackSentryError } from \"./lib/sentryErrorHandlers\";\nimport { updateSentryContext } from \"./lib/updateSentryContext\";\n\nexport type SliceMachineInitProcessOptions = {\n\trepository?: string;\n\tstarter?: string;\n\tdirectoryName?: string;\n\tpush?: boolean;\n\tpushSlices?: boolean;\n\tpushCustomTypes?: boolean;\n\tpushDocuments?: boolean;\n\tstartSlicemachine?: 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\tstartSlicemachine: 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?: PackageManager;\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\tstarterId?: StarterId;\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)} Initializing\\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.starter) {\n\t\t\t\tawait this.copyStarter();\n\t\t\t} else if (this.options.directoryName) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${logSymbols.warning} --directory-name has no effect because --starter is not specified\\n`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (await this.manager.telemetry.checkIsTelemetryEnabled()) {\n\t\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\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${\n\t\t\t\t\t\tlogSymbols.info\n\t\t\t\t\t} We collect telemetry data to improve user experience.\\n Learn more: ${chalk.cyan(\n\t\t\t\t\t\t\"https://prismic.dev/slice-machine/telemetry\",\n\t\t\t\t\t)}\\n`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait this.manager.telemetry.initTelemetry({\n\t\t\t\tappName: pkg.name,\n\t\t\t\tappVersion: pkg.version,\n\t\t\t});\n\t\t\tawait setupSentry();\n\t\t\tawait this.manager.telemetry.track({\n\t\t\t\tevent: \"command:init:start\",\n\t\t\t\trepository: this.options.repository,\n\t\t\t});\n\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\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.loginAndFetchUserData();\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\tawait this.finishCoreDependenciesInstallation();\n\t\t\tawait this.upsertSliceMachineConfigurationAndStartPluginRunner();\n\n\t\t\tconst isLoginRequired = await this.checkIsLoginRequired();\n\t\t\tif (isLoginRequired) {\n\t\t\t\tawait this.loginAndFetchUserData();\n\t\t\t\tif (this.context.repository.exists) {\n\t\t\t\t\tthis.validateWriteAccess();\n\t\t\t\t}\n\t\t\t}\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.syncDataWithPrismic();\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.sliceMachineTelemetryID,\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)} Initialization successful!\n\nContinue with next steps in Slice Machine.\n`,\n\t\t);\n\n\t\ttry {\n\t\t\tif (this.options.startSlicemachine) {\n\t\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t\t })\n\t\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t\t });\n\n\t\t\t\tconst { startSlicemachine } = await prompt<\n\t\t\t\t\tboolean,\n\t\t\t\t\t\"startSlicemachine\"\n\t\t\t\t>({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"startSlicemachine\",\n\t\t\t\t\tmessage: `Run Slice Machine (${chalk.cyan(runSmCommand)})?`,\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (startSlicemachine) {\n\t\t\t\t\tconst commandReturnValue = await execaCommand(runSmCommand, {\n\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t}).pipeStdout?.(process.stdout);\n\t\t\t\t\tif (commandReturnValue !== undefined) {\n\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\tconsole.log(commandReturnValue.stdout);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// Only track this error with Sentry, it's only the final convenience message\n\t\t\tawait this.trackSentryError(error);\n\t\t}\n\t}\n\n\tprotected async checkIsLoginRequired(): Promise<boolean> {\n\t\ttry {\n\t\t\tassertExists(this.context.repository, \"\");\n\t\t\tif (this.context.repository.exists === false) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tconst [slices, ctLibrary, documentsGlob] = await Promise.all([\n\t\t\t\tthis.readAllSlices(),\n\t\t\t\tthis.manager.customTypes.readCustomTypeLibrary(),\n\t\t\t\tthis.readDocuments(),\n\t\t\t]);\n\n\t\t\t// If repository exists, and there's anything to push\n\t\t\tif (\n\t\t\t\tslices.length > 0 ||\n\t\t\t\tctLibrary.ids.length > 0 ||\n\t\t\t\t(documentsGlob !== undefined && documentsGlob.documents.length > 0)\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// If repository exists, and there might be things to pull\n\t\t\tif (ctLibrary.ids.length === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprotected trackError = async (error: unknown): Promise<void> => {\n\t\tawait this.trackSentryError(error);\n\t\tawait this.trackTelemetryError(error);\n\t};\n\n\tprotected trackTelemetryError = async (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\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"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 trackSentryError = async (error: unknown): Promise<void> => {\n\t\tawait updateSentryContext({\n\t\t\tmanager: this.manager,\n\t\t\trepositoryName: this.context.repository?.domain || \"\",\n\t\t\tframework: this.context.framework?.sliceMachineTelemetryID ?? \"unknown\",\n\t\t});\n\t\ttrackSentryError(error);\n\t};\n\n\tprotected async copyStarter(): Promise<void> {\n\t\tconst dir = await this.getStarterDirectoryName();\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Copying starter...\\n\",\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tconst starter = this.options.starter;\n\n\t\t\t\t\tawait downloadTemplate(\n\t\t\t\t\t\t`${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdir,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\tprocess.chdir(dir);\n\t\t\t\t\tthis.manager.cwd = process.cwd();\n\n\t\t\t\t\ttask.title = \"Starter copied\\n\";\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected async getStarterDirectoryName(): Promise<string> {\n\t\tlet directoryName: string;\n\t\tconst folderNames = await fs.readdir(process.cwd());\n\n\t\tif (\n\t\t\tthis.options.directoryName &&\n\t\t\t!folderNames.includes(this.options.directoryName)\n\t\t) {\n\t\t\t// Use provided directory\n\t\t\tdirectoryName = this.options.directoryName;\n\t\t} else if (\n\t\t\tthis.options.repository &&\n\t\t\t!folderNames.includes(this.options.repository)\n\t\t) {\n\t\t\t// Use repository name\n\t\t\tdirectoryName = this.options.repository;\n\t\t} else {\n\t\t\t// Use random name\n\t\t\tlet suggestedName: string;\n\t\t\tdo {\n\t\t\t\tsuggestedName = getRandomRepositoryDomain();\n\t\t\t} while (folderNames.includes(suggestedName));\n\n\t\t\tconst { selectedDirectory } = await prompt<string, \"selectedDirectory\">({\n\t\t\t\ttype: \"text\",\n\t\t\t\tname: \"selectedDirectory\",\n\t\t\t\tmessage: \"Your starter directory name\",\n\t\t\t\tinitial: suggestedName,\n\t\t\t\tvalidate: async (rawDirectory: string) => {\n\t\t\t\t\tif (folderNames.includes(rawDirectory)) {\n\t\t\t\t\t\treturn \"Directory name already exists\";\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tdirectoryName = selectedDirectory;\n\t\t}\n\n\t\treturn directoryName;\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 =\n\t\t\t\t\t\t\t\t\tawait this.manager.project.detectPackageManager({\n\t\t\t\t\t\t\t\t\t\troot: this.manager.cwd,\n\t\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\t{\n\t\t\t\t\t\t\ttitle: \"Detecting starter...\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tthis.context.starterId = await detectStarterId(\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\tif (this.context.starterId) {\n\t\t\t\t\t\t\t\t\ttask.title = `Detected starter ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\tthis.context.starterId,\n\t\t\t\t\t\t\t\t\t)}`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\ttask.title = \"No starter detected\";\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 } =\n\t\t\t\t\t\tawait this.manager.project.installDependencies({\n\t\t\t\t\t\t\tpackageManager: this.context.packageManager,\n\t\t\t\t\t\t\tdependencies: this.context.framework.devDependencies,\n\t\t\t\t\t\t\tdev: true,\n\t\t\t\t\t\t\t// Picked up later\n\t\t\t\t\t\t\tlog: () => {\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\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);\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 async fetchUserProfile(): Promise<void> {\n\t\tthis.context.userProfile = await this.manager.user.getProfile();\n\n\t\tawait this.manager.telemetry.identify({\n\t\t\tuserID: this.context.userProfile.shortId,\n\t\t\tintercomHash: this.context.userProfile.intercomHash,\n\t\t});\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:identify\",\n\t\t\trepository: this.options.repository,\n\t\t});\n\t}\n\n\tprotected async fetchUserRepositories(): Promise<void> {\n\t\tthis.context.userRepositories =\n\t\t\tawait this.manager.prismicRepository.readAll();\n\t}\n\n\tprotected validateWriteAccess(): void {\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\tassertExists(\n\t\t\tthis.context.userRepositories,\n\t\t\t\"User repositories must be available through context to validate write access\",\n\t\t);\n\t\tconst { domain } = this.context.repository;\n\t\tconst maybeRepository = this.context.userRepositories.find(\n\t\t\t(repository) => repository.domain === domain,\n\t\t);\n\n\t\tif (maybeRepository) {\n\t\t\tif (!this.manager.prismicRepository.hasWriteAccess(maybeRepository)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot run init command with repository ${chalk.cyan(\n\t\t\t\t\t\tmaybeRepository.domain,\n\t\t\t\t\t)}: you are not a developer or admin of this repository`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot validate write access for repository ${chalk.cyan(\n\t\t\t\t\tdomain,\n\t\t\t\t)}: you are not part of this repository`,\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 this.pressKeyToLogin();\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\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\tawait this.fetchUserProfile();\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\tawait this.fetchUserRepositories();\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 async pressKeyToLogin(): Promise<void> {\n\t\tawait new Promise((resolve) => {\n\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\tprocess.stdin.resume();\n\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\tprocess.stdin.pause();\n\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t});\n\t\t});\n\t}\n\n\tprotected async waitingForLogin(): Promise<void> {\n\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\tawait this.manager.user.nodeLoginSession({\n\t\t\tport,\n\t\t\tonListenCallback() {\n\t\t\t\topen(url);\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.options.repository,\n\t\t\t\t\t\t\"Flag `repository` must be set to run `useRepositoryFlag`\",\n\t\t\t\t\t);\n\t\t\t\t\tconst domain = formatRepositoryDomain(this.options.repository);\n\t\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t\t});\n\n\t\t\t\t\tif (validation.LessThanMin || validation.MoreThanMax) {\n\t\t\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\t\t\tvalidation: {\n\t\t\t\t\t\t\t\t...validation,\n\t\t\t\t\t\t\t\t// We don't want to throw if repo already exists.\n\t\t\t\t\t\t\t\t// User most probably just created it via their dashboard.\n\t\t\t\t\t\t\t\tAlreadyExists: false,\n\t\t\t\t\t\t\t},\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: validation.AlreadyExists ?? false,\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 directory name\n\t\tconst maybeSuggestion = await trySuggestName(\n\t\t\tpath.basename(this.manager.cwd),\n\t\t);\n\t\tif (maybeSuggestion) {\n\t\t\tsuggestedName = maybeSuggestion;\n\t\t}\n\n\t\t// 2. Try to suggest name after package name\n\t\tif (!suggestedName) {\n\t\t\ttry {\n\t\t\t\tconst pkgJSONPath = path.join(this.manager.cwd, \"package.json\");\n\t\t\t\tconst pkg = JSON.parse(await fs.readFile(pkgJSONPath, \"utf-8\"));\n\n\t\t\t\tconst maybeSuggestion = await trySuggestName(pkg.name);\n\t\t\t\tif (maybeSuggestion) {\n\t\t\t\t\tsuggestedName = maybeSuggestion;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Noop\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.LessThanMin\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Min + \" characters long or more\",\n\t\t\t\t\t )}`;\n\n\t\t\t\tconst maxRule = validation.MoreThanMax\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\n\t\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t\t\t)}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\n\t\t\t\t\t\t\tREPOSITORY_NAME_VALIDATION.Max + \" characters long or less\",\n\t\t\t\t\t )}`;\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\ttry {\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t// When we have an error here, it's most probably because the user has a stale SESSION cookie\n\n\t\t\t\t\t\t// Ensure to logout user to remove SESSION and prismic-auth cookies\n\t\t\t\t\t\tawait this.manager.user.logout();\n\n\t\t\t\t\t\t// Force a new login to get a brand new cookies value\n\t\t\t\t\t\ttask.output =\n\t\t\t\t\t\t\t\"It seems there is an authentication problem, press any key to open the browser to login again...\";\n\t\t\t\t\t\tawait this.pressKeyToLogin();\n\t\t\t\t\t\ttask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tawait this.waitingForLogin();\n\n\t\t\t\t\t\t// Try to create repository again with the new cookies value\n\t\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.output = \"\";\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\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t// title: \"Starting plugin runner...\",\n\t\t\t\t\t\t\ttitle: \"Loading adapter...\",\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\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// task.title = \"Started plugin runner\";\n\t\t\t\t\t\t\t\ttask.title = \"Loaded adapter\";\n\t\t\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t\t\t// parentTask.title = `${parentTask.title} and started plugin runner`;\n\t\t\t\t\t\t\t\tparentTask.title = `${parentTask.title} and loaded adapter`;\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 async readAllSlices(): Promise<\n\t\t{ libraryID: string; sliceID: string }[]\n\t> {\n\t\tconst { libraries, errors } =\n\t\t\tawait this.manager.slices.readAllSliceLibraries();\n\n\t\tif (errors.length > 0) {\n\t\t\t// TODO: Provide better error message.\n\t\t\tthrow new Error(`Failed to read slice libraries: ${errors.join(\", \")}`);\n\t\t}\n\n\t\tconst slices: { libraryID: string; sliceID: string }[] = [];\n\t\tfor (const library of libraries) {\n\t\t\tif (library.sliceIDs) {\n\t\t\t\tfor (const sliceID of library.sliceIDs) {\n\t\t\t\t\tslices.push({\n\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\tsliceID,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn slices;\n\t}\n\n\tprotected async readDocuments(): Promise<\n\t\t| {\n\t\t\t\tsignature: string;\n\t\t\t\tdocuments: string[];\n\t\t\t\tdirectoryPath: string;\n\t\t }\n\t\t| undefined\n\t> {\n\t\tconst root = await this.manager.project.getRoot();\n\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\ttry {\n\t\t\tawait fs.access(documentsDirectoryPath);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tconst signaturePath = path.resolve(documentsDirectoryPath, \"index.json\");\n\t\tconst rawSignature = await fs.readFile(signaturePath, \"utf-8\");\n\t\tconst signature: string = JSON.parse(rawSignature).signature;\n\n\t\tconst documents = await globby(\"*/*.json\", {\n\t\t\tcwd: documentsDirectoryPath,\n\t\t});\n\n\t\treturn { signature, documents, directoryPath: documentsDirectoryPath };\n\t}\n\n\tprotected syncDataWithPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Syncing data with 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 slices = await this.readAllSlices();\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\ttask.title = \"Pushing slices... (initializing ACL)\";\n\t\t\t\t\t\t\t\tawait this.manager.screenshots.initS3ACL();\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({\n\t\t\t\t\t\t\t\t\t\t\t...slice,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\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 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 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({\n\t\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\t\tuserAgent: SLICE_MACHINE_INIT_USER_AGENT,\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\tpushed++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pushing 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 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 `syncDataWithPrismic`\",\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 documentsRead = await this.readDocuments();\n\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\tdocumentsRead === undefined ||\n\t\t\t\t\t\t\t\t\t\tdocumentsRead.documents.length === 0\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tconst { signature, documents, directoryPath } = documentsRead;\n\n\t\t\t\t\t\t\t\t\t// TODO: Replace `unknown` with a Prismic document type.\n\t\t\t\t\t\t\t\t\t// The exact format is not know at this time, hence the `unknown`.\n\t\t\t\t\t\t\t\t\tconst recordDocument: Record<string, unknown> = {};\n\n\t\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\t\tdocuments.map(async (documentPath) => {\n\t\t\t\t\t\t\t\t\t\t\tconst filename = path.basename(documentPath, \".json\");\n\t\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\t\tpath.resolve(directoryPath, documentPath),\n\t\t\t\t\t\t\t\t\t\t\t\t\"utf-8\",\n\t\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\t\t\t// TOOD: Validate the contents of the JSON file and skip on invalid documents.\n\t\t\t\t\t\t\t\t\t\t\t\tconst parsedContents = JSON.parse(fileContent);\n\n\t\t\t\t\t\t\t\t\t\t\t\trecordDocument[filename] = parsedContents;\n\t\t\t\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t\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\t\t\t\t\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t\t\t\t\t\t`Skipped document due to its invalid format: ${documentPath}`,\n\t\t\t\t\t\t\t\t\t\t\t\t);\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\n\t\t\t\t\t\t\t\t\tawait this.manager.prismicRepository.pushDocuments({\n\t\t\t\t\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\t\t\t\t\tdocuments: recordDocument,\n\t\t\t\t\t\t\t\t\t\tsignature,\n\t\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t\ttask.title = \"Pushed all documents\";\n\t\t\t\t\t\t\t\t} catch {\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\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},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pulling existing types...\",\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(\"Types already exist\");\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with Prismic\";\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 remoteTypes =\n\t\t\t\t\t\t\t\t\tawait this.manager.customTypes.fetchRemoteCustomTypes();\n\n\t\t\t\t\t\t\t\tconst createCustomTypeLimit = pLimit(8);\n\n\t\t\t\t\t\t\t\tlet pulled = 0;\n\t\t\t\t\t\t\t\ttask.title = `Pulling existing types... (0/${remoteTypes.length})`;\n\t\t\t\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\t\t\t\tremoteTypes.map(async (model) => {\n\t\t\t\t\t\t\t\t\t\tawait createCustomTypeLimit(() =>\n\t\t\t\t\t\t\t\t\t\t\tthis.manager.customTypes.createCustomType({ model }),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\tpulled++;\n\t\t\t\t\t\t\t\t\t\ttask.title = `Pulling existing types... (${pulled}/${remoteTypes.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 = \"Pulled existing types\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Synced data with 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\t{\n\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t// title: \"Initializing plugins...\",\n\t\t\t\t\ttitle: \"Initializing adapter...\",\n\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\tconst updateOutput = (data: Buffer | string | null) => {\n\t\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t\t} else if (typeof data === \"string\") {\n\t\t\t\t\t\t\t\ttask.output = data;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tawait this.manager.project.initProject({\n\t\t\t\t\t\t\tlog: updateOutput,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\t// TODO: Revert when plugin are introduced to users\n\t\t\t\t\t\t// task.title = \"Initialized plugins\";\n\t\t\t\t\t\ttask.title = \"Initialized adapter\";\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t{ exitOnError: false },\n\t\t).catch(() => void 0);\n\t}\n}\n"],"names":["_","_b","_a","domain","pkg","maybeSuggestion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,kBAAkD;AAAA,EACvD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,mBAAmB;;AAGP,MAAA,gCAAgC,CAC5C,YAC4B;AACrB,SAAA,IAAI,wBAAwB,OAAO;AAC3C;MAkBa,wBAAuB;AAAA,EAMnC,YAAY,SAAwC;AAL1C;AACA;AAEA;AAsLA,sCAAa,OAAO,UAAiC;AACxD,YAAA,KAAK,iBAAiB,KAAK;AAC3B,YAAA,KAAK,oBAAoB,KAAK;AAAA,IAAA;AAG3B,+CAAsB,OAAO,UAAiC;;AAEjE,YAAA,aACL,iBAAiB,QAAQ,MAAM,UAAU,GAAG,SAC3C,MAAM,GAAG,GAAG;AACR,YAAA,KAAK,QAAQ,UAAU,MAAM;AAAA,QAClC,OAAO;AAAA,QACP,aAAW,UAAK,QAAQ,cAAb,mBAAwB,4BAA2B;AAAA,QAC9D,cAAY,UAAK,QAAQ,eAAb,mBAAyB,WAAU;AAAA,QAC/C,SAAS;AA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ty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
var __accessCheck = (obj, member, msg) => {
|
|
9
|
+
if (!member.has(obj))
|
|
10
|
+
throw TypeError("Cannot " + msg);
|
|
11
|
+
};
|
|
12
|
+
var __privateGet = (obj, member, getter) => {
|
|
13
|
+
__accessCheck(obj, member, "read from private field");
|
|
14
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
15
|
+
};
|
|
16
|
+
var __privateAdd = (obj, member, value) => {
|
|
17
|
+
if (member.has(obj))
|
|
18
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
19
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
20
|
+
};
|
|
21
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
22
|
+
__accessCheck(obj, member, "write to private field");
|
|
23
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
27
|
+
set _(value) {
|
|
28
|
+
__privateSet(obj, member, value, setter);
|
|
29
|
+
},
|
|
30
|
+
get _() {
|
|
31
|
+
return __privateGet(obj, member, getter);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var _head, _tail, _size;
|
|
35
|
+
class Node {
|
|
36
|
+
constructor(value) {
|
|
37
|
+
__publicField(this, "value");
|
|
38
|
+
__publicField(this, "next");
|
|
39
|
+
this.value = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class Queue {
|
|
43
|
+
constructor() {
|
|
44
|
+
__privateAdd(this, _head, void 0);
|
|
45
|
+
__privateAdd(this, _tail, void 0);
|
|
46
|
+
__privateAdd(this, _size, void 0);
|
|
47
|
+
this.clear();
|
|
48
|
+
}
|
|
49
|
+
enqueue(value) {
|
|
50
|
+
const node = new Node(value);
|
|
51
|
+
if (__privateGet(this, _head)) {
|
|
52
|
+
__privateGet(this, _tail).next = node;
|
|
53
|
+
__privateSet(this, _tail, node);
|
|
54
|
+
} else {
|
|
55
|
+
__privateSet(this, _head, node);
|
|
56
|
+
__privateSet(this, _tail, node);
|
|
57
|
+
}
|
|
58
|
+
__privateWrapper(this, _size)._++;
|
|
59
|
+
}
|
|
60
|
+
dequeue() {
|
|
61
|
+
const current = __privateGet(this, _head);
|
|
62
|
+
if (!current) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
__privateSet(this, _head, __privateGet(this, _head).next);
|
|
66
|
+
__privateWrapper(this, _size)._--;
|
|
67
|
+
return current.value;
|
|
68
|
+
}
|
|
69
|
+
clear() {
|
|
70
|
+
__privateSet(this, _head, void 0);
|
|
71
|
+
__privateSet(this, _tail, void 0);
|
|
72
|
+
__privateSet(this, _size, 0);
|
|
73
|
+
}
|
|
74
|
+
get size() {
|
|
75
|
+
return __privateGet(this, _size);
|
|
76
|
+
}
|
|
77
|
+
*[Symbol.iterator]() {
|
|
78
|
+
let current = __privateGet(this, _head);
|
|
79
|
+
while (current) {
|
|
80
|
+
yield current.value;
|
|
81
|
+
current = current.next;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
_head = new WeakMap();
|
|
86
|
+
_tail = new WeakMap();
|
|
87
|
+
_size = new WeakMap();
|
|
88
|
+
module.exports = Queue;
|
|
89
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../../../node_modules/p-limit/node_modules/yocto-queue/index.js"],"sourcesContent":["/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,KAAK;AAAA,EAIV,YAAY,OAAO;AAHnB;AACA;AAGC,SAAK,QAAQ;AAAA,EACb;AACF;AAEe,MAAM,MAAM;AAAA,EAK1B,cAAc;AAJd;AACA;AACA;AAGC,SAAK,MAAK;AAAA,EACV;AAAA,EAED,QAAQ,OAAO;AACd,UAAM,OAAO,IAAI,KAAK,KAAK;AAE3B,QAAI,mBAAK,QAAO;AACf,yBAAK,OAAM,OAAO;AAClB,yBAAK,OAAQ;AAAA,IAChB,OAAS;AACN,yBAAK,OAAQ;AACb,yBAAK,OAAQ;AAAA,IACb;AAED,2BAAK,OAAL;AAAA,EACA;AAAA,EAED,UAAU;AACT,UAAM,UAAU,mBAAK;AACrB,QAAI,CAAC,SAAS;AACb;AAAA,IACA;AAED,uBAAK,OAAQ,mBAAK,OAAM;AACxB,2BAAK,OAAL;AACA,WAAO,QAAQ;AAAA,EACf;AAAA,EAED,QAAQ;AACP,uBAAK,OAAQ;AACb,uBAAK,OAAQ;AACb,uBAAK,OAAQ;AAAA,EACb;AAAA,EAED,IAAI,OAAO;AACV,WAAO,mBAAK;AAAA,EACZ;AAAA,EAED,EAAG,OAAO,QAAQ,IAAI;AACrB,QAAI,UAAU,mBAAK;AAEnB,WAAO,SAAS;AACf,YAAM,QAAQ;AACd,gBAAU,QAAQ;AAAA,IAClB;AAAA,EACD;AACF;AAnDC;AACA;AACA;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
var __accessCheck = (obj, member, msg) => {
|
|
8
|
+
if (!member.has(obj))
|
|
9
|
+
throw TypeError("Cannot " + msg);
|
|
10
|
+
};
|
|
11
|
+
var __privateGet = (obj, member, getter) => {
|
|
12
|
+
__accessCheck(obj, member, "read from private field");
|
|
13
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
14
|
+
};
|
|
15
|
+
var __privateAdd = (obj, member, value) => {
|
|
16
|
+
if (member.has(obj))
|
|
17
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
18
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
19
|
+
};
|
|
20
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
21
|
+
__accessCheck(obj, member, "write to private field");
|
|
22
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
26
|
+
set _(value) {
|
|
27
|
+
__privateSet(obj, member, value, setter);
|
|
28
|
+
},
|
|
29
|
+
get _() {
|
|
30
|
+
return __privateGet(obj, member, getter);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var _head, _tail, _size;
|
|
34
|
+
class Node {
|
|
35
|
+
constructor(value) {
|
|
36
|
+
__publicField(this, "value");
|
|
37
|
+
__publicField(this, "next");
|
|
38
|
+
this.value = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class Queue {
|
|
42
|
+
constructor() {
|
|
43
|
+
__privateAdd(this, _head, void 0);
|
|
44
|
+
__privateAdd(this, _tail, void 0);
|
|
45
|
+
__privateAdd(this, _size, void 0);
|
|
46
|
+
this.clear();
|
|
47
|
+
}
|
|
48
|
+
enqueue(value) {
|
|
49
|
+
const node = new Node(value);
|
|
50
|
+
if (__privateGet(this, _head)) {
|
|
51
|
+
__privateGet(this, _tail).next = node;
|
|
52
|
+
__privateSet(this, _tail, node);
|
|
53
|
+
} else {
|
|
54
|
+
__privateSet(this, _head, node);
|
|
55
|
+
__privateSet(this, _tail, node);
|
|
56
|
+
}
|
|
57
|
+
__privateWrapper(this, _size)._++;
|
|
58
|
+
}
|
|
59
|
+
dequeue() {
|
|
60
|
+
const current = __privateGet(this, _head);
|
|
61
|
+
if (!current) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
__privateSet(this, _head, __privateGet(this, _head).next);
|
|
65
|
+
__privateWrapper(this, _size)._--;
|
|
66
|
+
return current.value;
|
|
67
|
+
}
|
|
68
|
+
clear() {
|
|
69
|
+
__privateSet(this, _head, void 0);
|
|
70
|
+
__privateSet(this, _tail, void 0);
|
|
71
|
+
__privateSet(this, _size, 0);
|
|
72
|
+
}
|
|
73
|
+
get size() {
|
|
74
|
+
return __privateGet(this, _size);
|
|
75
|
+
}
|
|
76
|
+
*[Symbol.iterator]() {
|
|
77
|
+
let current = __privateGet(this, _head);
|
|
78
|
+
while (current) {
|
|
79
|
+
yield current.value;
|
|
80
|
+
current = current.next;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_head = new WeakMap();
|
|
85
|
+
_tail = new WeakMap();
|
|
86
|
+
_size = new WeakMap();
|
|
87
|
+
export {
|
|
88
|
+
Queue as default
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../node_modules/p-limit/node_modules/yocto-queue/index.js"],"sourcesContent":["/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nexport default class Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAKA,MAAM,KAAK;AAAA,EAIV,YAAY,OAAO;AAHnB;AACA;AAGC,SAAK,QAAQ;AAAA,EACb;AACF;AAEe,MAAM,MAAM;AAAA,EAK1B,cAAc;AAJd;AACA;AACA;AAGC,SAAK,MAAK;AAAA,EACV;AAAA,EAED,QAAQ,OAAO;AACd,UAAM,OAAO,IAAI,KAAK,KAAK;AAE3B,QAAI,mBAAK,QAAO;AACf,yBAAK,OAAM,OAAO;AAClB,yBAAK,OAAQ;AAAA,IAChB,OAAS;AACN,yBAAK,OAAQ;AACb,yBAAK,OAAQ;AAAA,IACb;AAED,2BAAK,OAAL;AAAA,EACA;AAAA,EAED,UAAU;AACT,UAAM,UAAU,mBAAK;AACrB,QAAI,CAAC,SAAS;AACb;AAAA,IACA;AAED,uBAAK,OAAQ,mBAAK,OAAM;AACxB,2BAAK,OAAL;AACA,WAAO,QAAQ;AAAA,EACf;AAAA,EAED,QAAQ;AACP,uBAAK,OAAQ;AACb,uBAAK,OAAQ;AACb,uBAAK,OAAQ;AAAA,EACb;AAAA,EAED,IAAI,OAAO;AACV,WAAO,mBAAK;AAAA,EACZ;AAAA,EAED,EAAG,OAAO,QAAQ,IAAI;AACrB,QAAI,UAAU,mBAAK;AAEnB,WAAO,SAAS;AACf,YAAM,QAAQ;AACd,gBAAU,QAAQ;AAAA,IAClB;AAAA,EACD;AACF;AAnDC;AACA;AACA;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const index = require('./_node_modules/yocto-queue/index.cjs');
|
|
3
|
+
function pLimit(concurrency) {
|
|
4
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
5
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
6
|
+
}
|
|
7
|
+
const queue = new index();
|
|
8
|
+
let activeCount = 0;
|
|
9
|
+
const next = () => {
|
|
10
|
+
activeCount--;
|
|
11
|
+
if (queue.size > 0) {
|
|
12
|
+
queue.dequeue()();
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const run = async (fn, resolve, args) => {
|
|
16
|
+
activeCount++;
|
|
17
|
+
const result = (async () => fn(...args))();
|
|
18
|
+
resolve(result);
|
|
19
|
+
try {
|
|
20
|
+
await result;
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
next();
|
|
24
|
+
};
|
|
25
|
+
const enqueue = (fn, resolve, args) => {
|
|
26
|
+
queue.enqueue(run.bind(void 0, fn, resolve, args));
|
|
27
|
+
(async () => {
|
|
28
|
+
await Promise.resolve();
|
|
29
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
30
|
+
queue.dequeue()();
|
|
31
|
+
}
|
|
32
|
+
})();
|
|
33
|
+
};
|
|
34
|
+
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
35
|
+
enqueue(fn, resolve, args);
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperties(generator, {
|
|
38
|
+
activeCount: {
|
|
39
|
+
get: () => activeCount
|
|
40
|
+
},
|
|
41
|
+
pendingCount: {
|
|
42
|
+
get: () => queue.size
|
|
43
|
+
},
|
|
44
|
+
clearQueue: {
|
|
45
|
+
value: () => {
|
|
46
|
+
queue.clear();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return generator;
|
|
51
|
+
}
|
|
52
|
+
module.exports = pLimit;
|
|
53
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../../node_modules/p-limit/index.js"],"sourcesContent":["import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n"],"names":["Queue"],"mappings":";;AAEe,SAAS,OAAO,aAAa;AAC3C,MAAI,GAAG,OAAO,UAAU,WAAW,KAAK,gBAAgB,OAAO,sBAAsB,cAAc,IAAI;AACtG,UAAM,IAAI,UAAU,qDAAqD;AAAA,EACzE;AAED,QAAM,QAAQ,IAAIA;AAClB,MAAI,cAAc;AAElB,QAAM,OAAO,MAAM;AAClB;AAEA,QAAI,MAAM,OAAO,GAAG;AACnB,YAAM,QAAO;IACb;AAAA,EACH;AAEC,QAAM,MAAM,OAAO,IAAI,SAAS,SAAS;AACxC;AAEA,UAAM,UAAU,YAAY,GAAG,GAAG,IAAI,GAAC;AAEvC,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACN,QAAC;AAAA,IAAQ;AAEV;EACF;AAEC,QAAM,UAAU,CAAC,IAAI,SAAS,SAAS;AACtC,UAAM,QAAQ,IAAI,KAAK,QAAW,IAAI,SAAS,IAAI,CAAC;AAEpD,KAAC,YAAY;AAKZ,YAAM,QAAQ;AAEd,UAAI,cAAc,eAAe,MAAM,OAAO,GAAG;AAChD,cAAM,QAAO;MACb;AAAA,IACJ;EACA;AAEC,QAAM,YAAY,CAAC,OAAO,SAAS,IAAI,QAAQ,aAAW;AACzD,YAAQ,IAAI,SAAS,IAAI;AAAA,EAC3B,CAAE;AAED,SAAO,iBAAiB,WAAW;AAAA,IAClC,aAAa;AAAA,MACZ,KAAK,MAAM;AAAA,IACX;AAAA,IACD,cAAc;AAAA,MACb,KAAK,MAAM,MAAM;AAAA,IACjB;AAAA,IACD,YAAY;AAAA,MACX,OAAO,MAAM;AACZ,cAAM,MAAK;AAAA,MACX;AAAA,IACD;AAAA,EACH,CAAE;AAED,SAAO;AACR;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import Queue from './_node_modules/yocto-queue/index.js';
|
|
2
|
+
function pLimit(concurrency) {
|
|
3
|
+
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
|
|
4
|
+
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
5
|
+
}
|
|
6
|
+
const queue = new Queue();
|
|
7
|
+
let activeCount = 0;
|
|
8
|
+
const next = () => {
|
|
9
|
+
activeCount--;
|
|
10
|
+
if (queue.size > 0) {
|
|
11
|
+
queue.dequeue()();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const run = async (fn, resolve, args) => {
|
|
15
|
+
activeCount++;
|
|
16
|
+
const result = (async () => fn(...args))();
|
|
17
|
+
resolve(result);
|
|
18
|
+
try {
|
|
19
|
+
await result;
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
next();
|
|
23
|
+
};
|
|
24
|
+
const enqueue = (fn, resolve, args) => {
|
|
25
|
+
queue.enqueue(run.bind(void 0, fn, resolve, args));
|
|
26
|
+
(async () => {
|
|
27
|
+
await Promise.resolve();
|
|
28
|
+
if (activeCount < concurrency && queue.size > 0) {
|
|
29
|
+
queue.dequeue()();
|
|
30
|
+
}
|
|
31
|
+
})();
|
|
32
|
+
};
|
|
33
|
+
const generator = (fn, ...args) => new Promise((resolve) => {
|
|
34
|
+
enqueue(fn, resolve, args);
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperties(generator, {
|
|
37
|
+
activeCount: {
|
|
38
|
+
get: () => activeCount
|
|
39
|
+
},
|
|
40
|
+
pendingCount: {
|
|
41
|
+
get: () => queue.size
|
|
42
|
+
},
|
|
43
|
+
clearQueue: {
|
|
44
|
+
value: () => {
|
|
45
|
+
queue.clear();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return generator;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
pLimit as default
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../node_modules/p-limit/index.js"],"sourcesContent":["import Queue from 'yocto-queue';\n\nexport default function pLimit(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tif (queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t}\n\t};\n\n\tconst run = async (fn, resolve, args) => {\n\t\tactiveCount++;\n\n\t\tconst result = (async () => fn(...args))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (fn, resolve, args) => {\n\t\tqueue.enqueue(run.bind(undefined, fn, resolve, args));\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// when the run function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\t\tqueue.dequeue()();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (fn, ...args) => new Promise(resolve => {\n\t\tenqueue(fn, resolve, args);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue: () => {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n"],"names":[],"mappings":";AAEe,SAAS,OAAO,aAAa;AAC3C,MAAI,GAAG,OAAO,UAAU,WAAW,KAAK,gBAAgB,OAAO,sBAAsB,cAAc,IAAI;AACtG,UAAM,IAAI,UAAU,qDAAqD;AAAA,EACzE;AAED,QAAM,QAAQ,IAAI;AAClB,MAAI,cAAc;AAElB,QAAM,OAAO,MAAM;AAClB;AAEA,QAAI,MAAM,OAAO,GAAG;AACnB,YAAM,QAAO;IACb;AAAA,EACH;AAEC,QAAM,MAAM,OAAO,IAAI,SAAS,SAAS;AACxC;AAEA,UAAM,UAAU,YAAY,GAAG,GAAG,IAAI,GAAC;AAEvC,YAAQ,MAAM;AAEd,QAAI;AACH,YAAM;AAAA,IACN,QAAC;AAAA,IAAQ;AAEV;EACF;AAEC,QAAM,UAAU,CAAC,IAAI,SAAS,SAAS;AACtC,UAAM,QAAQ,IAAI,KAAK,QAAW,IAAI,SAAS,IAAI,CAAC;AAEpD,KAAC,YAAY;AAKZ,YAAM,QAAQ;AAEd,UAAI,cAAc,eAAe,MAAM,OAAO,GAAG;AAChD,cAAM,QAAO;MACb;AAAA,IACJ;EACA;AAEC,QAAM,YAAY,CAAC,OAAO,SAAS,IAAI,QAAQ,aAAW;AACzD,YAAQ,IAAI,SAAS,IAAI;AAAA,EAC3B,CAAE;AAED,SAAO,iBAAiB,WAAW;AAAA,IAClC,aAAa;AAAA,MACZ,KAAK,MAAM;AAAA,IACX;AAAA,IACD,cAAc;AAAA,MACb,KAAK,MAAM,MAAM;AAAA,IACjB;AAAA,IACD,YAAY;AAAA,MACX,OAAO,MAAM;AACZ,cAAM,MAAK;AAAA,MACX;AAAA,IACD;AAAA,EACH,CAAE;AAED,SAAO;AACR;","x_google_ignoreList":[0]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
3
|
const name = "@slicemachine/init";
|
|
4
|
-
const version = "2.9.3-dev-
|
|
4
|
+
const version = "2.9.3-dev-next-release.2";
|
|
5
5
|
const description = "Init Prismic Slice Machine in your project";
|
|
6
6
|
const keywords = [
|
|
7
7
|
"typescript",
|
|
@@ -55,7 +55,7 @@ const dependencies = {
|
|
|
55
55
|
"@antfu/ni": "^0.20.0",
|
|
56
56
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
57
57
|
"@sentry/node": "^7.70.0",
|
|
58
|
-
"@slicemachine/manager": "^0.15.4-dev-
|
|
58
|
+
"@slicemachine/manager": "^0.15.4-dev-next-release.2",
|
|
59
59
|
chalk: "^4.1.2",
|
|
60
60
|
giget: "^1.1.2",
|
|
61
61
|
globby: "^13.1.3",
|
|
@@ -63,12 +63,13 @@ const dependencies = {
|
|
|
63
63
|
"log-symbols": "^4.1.0",
|
|
64
64
|
meow: "^11.0.0",
|
|
65
65
|
open: "^8.4.2",
|
|
66
|
+
"p-limit": "^4.0.0",
|
|
66
67
|
prompts: "^2.4.2",
|
|
67
68
|
semver: "^7.3.8"
|
|
68
69
|
};
|
|
69
70
|
const devDependencies = {
|
|
70
71
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
71
|
-
"@slicemachine/plugin-kit": "0.4.25-dev-
|
|
72
|
+
"@slicemachine/plugin-kit": "0.4.25-dev-next-release.2",
|
|
72
73
|
"@types/listr": "0.14.4",
|
|
73
74
|
"@types/prompts": "2.4.3",
|
|
74
75
|
"@types/semver": "7.3.13",
|
|
@@ -94,7 +95,7 @@ const devDependencies = {
|
|
|
94
95
|
"vite-plugin-sdk": "0.1.1",
|
|
95
96
|
vitest: "0.32.0"
|
|
96
97
|
};
|
|
97
|
-
const gitHead = "
|
|
98
|
+
const gitHead = "e09124531c7330f402bd6286b1b524dfc4fc2139";
|
|
98
99
|
const pkg = {
|
|
99
100
|
name,
|
|
100
101
|
version,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const name = "@slicemachine/init";
|
|
2
|
-
const version = "2.9.3-dev-
|
|
2
|
+
const version = "2.9.3-dev-next-release.2";
|
|
3
3
|
const description = "Init Prismic Slice Machine in your project";
|
|
4
4
|
const keywords = [
|
|
5
5
|
"typescript",
|
|
@@ -53,7 +53,7 @@ const dependencies = {
|
|
|
53
53
|
"@antfu/ni": "^0.20.0",
|
|
54
54
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
55
55
|
"@sentry/node": "^7.70.0",
|
|
56
|
-
"@slicemachine/manager": "^0.15.4-dev-
|
|
56
|
+
"@slicemachine/manager": "^0.15.4-dev-next-release.2",
|
|
57
57
|
chalk: "^4.1.2",
|
|
58
58
|
giget: "^1.1.2",
|
|
59
59
|
globby: "^13.1.3",
|
|
@@ -61,12 +61,13 @@ const dependencies = {
|
|
|
61
61
|
"log-symbols": "^4.1.0",
|
|
62
62
|
meow: "^11.0.0",
|
|
63
63
|
open: "^8.4.2",
|
|
64
|
+
"p-limit": "^4.0.0",
|
|
64
65
|
prompts: "^2.4.2",
|
|
65
66
|
semver: "^7.3.8"
|
|
66
67
|
};
|
|
67
68
|
const devDependencies = {
|
|
68
69
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
69
|
-
"@slicemachine/plugin-kit": "0.4.25-dev-
|
|
70
|
+
"@slicemachine/plugin-kit": "0.4.25-dev-next-release.2",
|
|
70
71
|
"@types/listr": "0.14.4",
|
|
71
72
|
"@types/prompts": "2.4.3",
|
|
72
73
|
"@types/semver": "7.3.13",
|
|
@@ -92,7 +93,7 @@ const devDependencies = {
|
|
|
92
93
|
"vite-plugin-sdk": "0.1.1",
|
|
93
94
|
vitest: "0.32.0"
|
|
94
95
|
};
|
|
95
|
-
const gitHead = "
|
|
96
|
+
const gitHead = "e09124531c7330f402bd6286b1b524dfc4fc2139";
|
|
96
97
|
const pkg = {
|
|
97
98
|
name,
|
|
98
99
|
version,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/init",
|
|
3
|
-
"version": "2.9.3-dev-
|
|
3
|
+
"version": "2.9.3-dev-next-release.2",
|
|
4
4
|
"description": "Init Prismic Slice Machine in your project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@antfu/ni": "^0.20.0",
|
|
55
55
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
56
56
|
"@sentry/node": "^7.70.0",
|
|
57
|
-
"@slicemachine/manager": "^0.15.4-dev-
|
|
57
|
+
"@slicemachine/manager": "^0.15.4-dev-next-release.2",
|
|
58
58
|
"chalk": "^4.1.2",
|
|
59
59
|
"giget": "^1.1.2",
|
|
60
60
|
"globby": "^13.1.3",
|
|
@@ -62,12 +62,13 @@
|
|
|
62
62
|
"log-symbols": "^4.1.0",
|
|
63
63
|
"meow": "^11.0.0",
|
|
64
64
|
"open": "^8.4.2",
|
|
65
|
+
"p-limit": "^4.0.0",
|
|
65
66
|
"prompts": "^2.4.2",
|
|
66
67
|
"semver": "^7.3.8"
|
|
67
68
|
},
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@size-limit/preset-small-lib": "8.2.4",
|
|
70
|
-
"@slicemachine/plugin-kit": "0.4.25-dev-
|
|
71
|
+
"@slicemachine/plugin-kit": "0.4.25-dev-next-release.2",
|
|
71
72
|
"@types/listr": "0.14.4",
|
|
72
73
|
"@types/prompts": "2.4.3",
|
|
73
74
|
"@types/semver": "7.3.13",
|
|
@@ -93,5 +94,5 @@
|
|
|
93
94
|
"vite-plugin-sdk": "0.1.1",
|
|
94
95
|
"vitest": "0.32.0"
|
|
95
96
|
},
|
|
96
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "e09124531c7330f402bd6286b1b524dfc4fc2139"
|
|
97
98
|
}
|
|
@@ -9,6 +9,7 @@ import open from "open";
|
|
|
9
9
|
import logSymbols from "log-symbols";
|
|
10
10
|
import { globby } from "globby";
|
|
11
11
|
import { downloadTemplate } from "giget";
|
|
12
|
+
import pLimit from "p-limit";
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
createSliceMachineManager,
|
|
@@ -199,7 +200,7 @@ export class SliceMachineInitProcess {
|
|
|
199
200
|
`\n${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim(
|
|
200
201
|
"→",
|
|
201
202
|
)} Initialization successful!
|
|
202
|
-
|
|
203
|
+
|
|
203
204
|
Continue with next steps in Slice Machine.
|
|
204
205
|
`,
|
|
205
206
|
);
|
|
@@ -1286,9 +1287,17 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
1286
1287
|
const remoteTypes =
|
|
1287
1288
|
await this.manager.customTypes.fetchRemoteCustomTypes();
|
|
1288
1289
|
|
|
1290
|
+
const createCustomTypeLimit = pLimit(8);
|
|
1291
|
+
|
|
1292
|
+
let pulled = 0;
|
|
1293
|
+
task.title = `Pulling existing types... (0/${remoteTypes.length})`;
|
|
1289
1294
|
await Promise.all(
|
|
1290
1295
|
remoteTypes.map(async (model) => {
|
|
1291
|
-
await
|
|
1296
|
+
await createCustomTypeLimit(() =>
|
|
1297
|
+
this.manager.customTypes.createCustomType({ model }),
|
|
1298
|
+
);
|
|
1299
|
+
pulled++;
|
|
1300
|
+
task.title = `Pulling existing types... (${pulled}/${remoteTypes.length})`;
|
|
1292
1301
|
}),
|
|
1293
1302
|
);
|
|
1294
1303
|
|