@slicemachine/init 2.7.2-dev-upgrade-legacy.1 → 2.7.2-dev-next-release.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,7 +137,7 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
137
137
  if (!this.context.repository.exists) {
138
138
  await this.createNewRepository();
139
139
  }
140
- await this.syncDataWithPrismic();
140
+ await this.pushDataToPrismic();
141
141
  await this.initializeProject();
142
142
  await this.initializePlugins();
143
143
  } catch (error) {
@@ -240,9 +240,6 @@ ${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} I
240
240
  if (slices.length > 0 || ctLibrary.ids.length > 0 || documentsGlob !== void 0 && documentsGlob.documents.length > 0) {
241
241
  return true;
242
242
  }
243
- if (ctLibrary.ids.length === 0) {
244
- return true;
245
- }
246
243
  } catch (e) {
247
244
  return true;
248
245
  }
@@ -747,10 +744,10 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
747
744
  });
748
745
  return { signature, documents, directoryPath: documentsDirectoryPath };
749
746
  }
750
- syncDataWithPrismic() {
747
+ pushDataToPrismic() {
751
748
  return listr.listrRun([
752
749
  {
753
- title: "Syncing data with Prismic...",
750
+ title: "Pushing data to Prismic...",
754
751
  task: (_, parentTask) => listr.listr([
755
752
  {
756
753
  title: "Pushing slices...",
@@ -823,10 +820,11 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
823
820
  }
824
821
  },
825
822
  task: async (_2, task) => {
826
- assertExists.assertExists(this.context.repository, "Repository selection must be available through context to run `syncDataWithPrismic`");
823
+ assertExists.assertExists(this.context.repository, "Repository selection must be available through context to run `pushDataToPrismic`");
827
824
  try {
828
825
  const documentsRead = await this.readDocuments();
829
826
  if (documentsRead === void 0 || documentsRead.documents.length === 0) {
827
+ parentTask.title = "Pushed data to Prismic";
830
828
  task.skip("No document to push");
831
829
  return;
832
830
  }
@@ -848,7 +846,9 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
848
846
  signature
849
847
  });
850
848
  task.title = "Pushed all documents";
849
+ parentTask.title = "Pushed data to Prismic";
851
850
  } catch {
851
+ parentTask.title = "Pushed data to Prismic";
852
852
  task.skip("No document to push");
853
853
  return;
854
854
  }
@@ -867,26 +867,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
867
867
  } catch {
868
868
  }
869
869
  task.title = "Cleaned up data push artifacts";
870
- }
871
- },
872
- {
873
- title: "Pulling existing types...",
874
- task: async (_2, task) => {
875
- const { ids, errors } = await this.manager.customTypes.readCustomTypeLibrary();
876
- if (errors.length > 0) {
877
- throw new Error(`Failed to read custom type libraries: ${errors.join(", ")}`);
878
- }
879
- if (ids && ids.length > 0) {
880
- task.skip("Types already exists");
881
- parentTask.title = "Synced data with Prismic";
882
- return;
883
- }
884
- const remoteTypes = await this.manager.customTypes.fetchRemoteCustomTypes();
885
- await Promise.all(remoteTypes.map(async (model) => {
886
- await this.manager.customTypes.createCustomType({ model });
887
- }));
888
- task.title = "Pulled existing types";
889
- parentTask.title = "Synced data with Prismic";
870
+ parentTask.title = "Pushed data to Prismic";
890
871
  }
891
872
  }
892
873
  ])
@@ -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} 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);\n\n\t\ttry {\n\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t })\n\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t });\n\n\t\t\tconst runProjectCommand = await getRunScriptCommand({\n\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\tscript: \"dev\",\n\t\t\t});\n\n\t\t\tconst apiEndpoints = this.manager.getAPIEndpoints();\n\t\t\tconst wroomHost = new URL(apiEndpoints.PrismicWroom).host;\n\n\t\t\tconst dashboardURL = new URL(\n\t\t\t\t`https://${this.context.repository.domain}.${wroomHost}`,\n\t\t\t)\n\t\t\t\t.toString()\n\t\t\t\t.replace(/\\/$/, \"\");\n\t\t\tconst apiURL = new URL(\n\t\t\t\t\"./api/v2\",\n\t\t\t\t`https://${this.context.repository.domain}.cdn.${wroomHost}`,\n\t\t\t).toString();\n\n\t\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`\n YOUR REPOSITORY\n Page Builder ${chalk.cyan(dashboardURL)}\n API ${chalk.cyan(apiURL)}\n\n RESOURCES\n Documentation ${chalk.cyan(\n\t\t\tthis.context.framework.prismicDocumentation,\n\t\t)}\n Getting help ${chalk.cyan(\"https://community.prismic.io\")}\n\n GETTING STARTED\n Run Slice Machine ${chalk.cyan(runSmCommand)}\n Run your project ${chalk.cyan(runProjectCommand)}\n\t`);\n\n\t\t\tif (this.options.starter && this.options.repository) {\n\t\t\t\tconst { openDashboard } = await prompt<boolean, \"openDashboard\">({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"openDashboard\",\n\t\t\t\t\tmessage: \"Would you like to open your repository?\",\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (openDashboard) {\n\t\t\t\t\topen(dashboardURL);\n\t\t\t\t}\n\t\t\t} else if (this.options.startSlicemachine) {\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\t\t\t\tconst scripts = pkg.scripts || {};\n\n\t\t\t\tconst finalSmCommand = (() => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tscripts[\"dev\"] &&\n\t\t\t\t\t\ttypeof scripts[\"dev\"] === \"string\" &&\n\t\t\t\t\t\tscripts[\"dev\"].includes(\":slicemachine\")\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcommand: runProjectCommand,\n\t\t\t\t\t\t\tmessage: `Would you like to run your project and Slice Machine concurrently (${runProjectCommand})?`,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcommand: runSmCommand,\n\t\t\t\t\t\tmessage: `Would you like to run Slice Machine (${runSmCommand})?`,\n\t\t\t\t\t};\n\t\t\t\t})();\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: finalSmCommand.message,\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(\n\t\t\t\t\t\tfinalSmCommand.command,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t\t},\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 (e) {\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.shortMessage);\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${\n\t\t\t\t\t\t\t\tlogSymbols.error\n\t\t\t\t\t\t\t} Dependency installation failed, try again with:\\n\\n ${chalk.gray(\n\t\t\t\t\t\t\t\t\"$\",\n\t\t\t\t\t\t\t)} ${chalk.cyan(tryAgainCommand)}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.installProcess = execaProcess;\n\n\t\t\t\t\ttask.title = `Began core dependencies installation with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)} ... (running in background)`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected 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 new Promise((resolve) => {\n\t\t\t\t\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\t\t\t\t\tprocess.stdin.resume();\n\t\t\t\t\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\t\t\t\t\tawait this.manager.user.nodeLoginSession({\n\t\t\t\t\t\t\tport,\n\t\t\t\t\t\t\tonListenCallback() {\n\t\t\t\t\t\t\t\topen(url);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tparentTask.output = \"\";\n\t\t\t\t\tparentTask.title = `Logged in`;\n\n\t\t\t\t\treturn listr(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user profile...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\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 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.LessThan4 || validation.MoreThan30) {\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.LessThan4\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"4 characters long or more\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"4 characters long or more\")}`;\n\n\t\t\t\tconst maxRule = validation.MoreThan30\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"30 characters long or less\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"30 characters long or less\")}`;\n\n\t\t\t\tthis.msg = chalk.reset(\n\t\t\t\t\t`\nChoose a name for your Prismic repository\n\n NAMING RULES\n ${minRule}\n ${maxRule}\n 3. Name will be ${chalk.cyan(\"kebab-cased\")} automatically\n\n CONSIDERATIONS\n 1. Once picked, your repository name ${chalk.cyan(\"cannot be changed\")}\n 2. A ${chalk.cyan(\n\t\t\t\"display name\",\n\t\t)} for the repository can be configured later on\n\n PREVIEW\n Dashboard ${chalk.cyan(`https://${domain}.prismic.io`)}\n API ${chalk.cyan(`https://${domain}.cdn.prismic.io/api/v2`)}\n\n${chalk.cyan(\"?\")} Your Prismic repository name`.replace(\"\\n\", \"\"),\n\t\t\t\t);\n\t\t\t},\n\t\t\tvalidate: async (rawDomain: string) => {\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\tdomain,\n\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t});\n\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\tvalidation,\n\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t});\n\n\t\t\t\treturn errorMessage || true;\n\t\t\t},\n\t\t\tformat: (value) => {\n\t\t\t\treturn formatRepositoryDomain(value);\n\t\t\t},\n\t\t});\n\n\t\t// Clear extra lines\n\t\tprocess.stdout.moveCursor?.(0, -16);\n\t\tprocess.stdout.clearScreenDown?.();\n\n\t\tthis.context.repository = {\n\t\t\tdomain,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tprotected createNewRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t);\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Creating new repository ${chalk.cyan(\n\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.title = `Created new repository ${chalk.cyan(\n\t\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected finishCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Finishing core dependencies installation with ${chalk.cyan(\n\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.installProcess,\n\t\t\t\t\t\t\"Initial dependencies installation process must be available through context to run `finishCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst updateOutput = (data: Buffer | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Don't clutter console with logs when process is non TTY (CI, etc.)\n\t\t\t\t\tif (process.stdout.isTTY || process.env.NODE_ENV === \"test\") {\n\t\t\t\t\t\tthis.context.installProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t}\n\t\t\t\t\tthis.context.installProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.context.installProcess;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Error catching happens when then process is started ealier so\n\t\t\t\t\t\t * that all install errors, earlier and presents, can be catched.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * Here, we force the task to wait so that it is neither marked as\n\t\t\t\t\t\t * done or has the opportunity to handle the error itself.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t// If for whatever reason the process is not exited by now, we still throw the error\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 5000));\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Installed core dependencies with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Resolving Slice Machine configuration...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tlet sliceMachineConfigExists = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.manager.project.getSliceMachineConfigPath();\n\t\t\t\t\t\tsliceMachineConfigExists = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// noop, config does not exists, we'll create it\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sliceMachineConfigExists) {\n\t\t\t\t\t\tparentTask.title = \"Updating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst config = await this.manager.project.getSliceMachineConfig();\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tparentTask.title = \"Updated Slice Machine configuration\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentTask.title = \"Creating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst sliceMachineConfigPath =\n\t\t\t\t\t\t\tawait this.manager.project.suggestSliceMachineConfigPath();\n\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\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 exists\");\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","path","fs","execaCommand","listrRun","downloadTemplate","GIGET_PROVIDER","GIGET_ORGANIZATION","getRandomRepositoryDomain","listr","_","detectFramework","detectStarterId","_b","_a","formatRepositoryDomain","validateRepositoryDomainAndAvailability","domain","getErrorMessageForRepositoryDomainValidation","validateRepositoryDomain","maybeSuggestion","globby","SLICE_MACHINE_INIT_USER_AGENT","START_SCRIPT_KEY","START_SCRIPT_VALUE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,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;AA0PA,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;AAAA,QACT,OAAO;AAAA,MAAA,CACP;AAAA,IAAA;AAGQ,4CAAmB,OAAO,UAAiC;;AACpE,YAAMA,wCAAoB;AAAA,QACzB,SAAS,KAAK;AAAA,QACd,kBAAgB,UAAK,QAAQ,eAAb,mBAAyB,WAAU;AAAA,QACnD,aAAW,UAAK,QAAQ,cAAb,mBAAwB,4BAA2B;AAAA,MAAA,CAC9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KAChE,cAAc;AAGf;AAAA,gBACA;AAEI,2BAAA,SAAQ,0BAAR,GAAQ,wBAA0B;AAClC,qBAAA,QAAQ,sBAAsB,gBAAgB;AAEnD,qBAAK,QAAQ,WAAW,MAAM,KAAK,cAAc;AACjD,2BAAW,QAAQ,gCAAgC,MAAM,KACxD,cAAc;AAAA,cAEhB;AAAA,YACA;AAAA,UAAA,CACD;AAAA;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACF;AAAA,EAEU,oBAAiB;AAC1B,WAAOpB,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;;;"}
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} 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.pushDataToPrismic();\n\t\t\tawait this.initializeProject();\n\t\t\tawait this.initializePlugins();\n\t\t} catch (error) {\n\t\t\tawait this.trackError(error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework.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);\n\n\t\ttry {\n\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t })\n\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t });\n\n\t\t\tconst runProjectCommand = await getRunScriptCommand({\n\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\tscript: \"dev\",\n\t\t\t});\n\n\t\t\tconst apiEndpoints = this.manager.getAPIEndpoints();\n\t\t\tconst wroomHost = new URL(apiEndpoints.PrismicWroom).host;\n\n\t\t\tconst dashboardURL = new URL(\n\t\t\t\t`https://${this.context.repository.domain}.${wroomHost}`,\n\t\t\t)\n\t\t\t\t.toString()\n\t\t\t\t.replace(/\\/$/, \"\");\n\t\t\tconst apiURL = new URL(\n\t\t\t\t\"./api/v2\",\n\t\t\t\t`https://${this.context.repository.domain}.cdn.${wroomHost}`,\n\t\t\t).toString();\n\n\t\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`\n YOUR REPOSITORY\n Page Builder ${chalk.cyan(dashboardURL)}\n API ${chalk.cyan(apiURL)}\n\n RESOURCES\n Documentation ${chalk.cyan(\n\t\t\tthis.context.framework.prismicDocumentation,\n\t\t)}\n Getting help ${chalk.cyan(\"https://community.prismic.io\")}\n\n GETTING STARTED\n Run Slice Machine ${chalk.cyan(runSmCommand)}\n Run your project ${chalk.cyan(runProjectCommand)}\n\t`);\n\n\t\t\tif (this.options.starter && this.options.repository) {\n\t\t\t\tconst { openDashboard } = await prompt<boolean, \"openDashboard\">({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"openDashboard\",\n\t\t\t\t\tmessage: \"Would you like to open your repository?\",\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (openDashboard) {\n\t\t\t\t\topen(dashboardURL);\n\t\t\t\t}\n\t\t\t} else if (this.options.startSlicemachine) {\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\t\t\t\tconst scripts = pkg.scripts || {};\n\n\t\t\t\tconst finalSmCommand = (() => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tscripts[\"dev\"] &&\n\t\t\t\t\t\ttypeof scripts[\"dev\"] === \"string\" &&\n\t\t\t\t\t\tscripts[\"dev\"].includes(\":slicemachine\")\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcommand: runProjectCommand,\n\t\t\t\t\t\t\tmessage: `Would you like to run your project and Slice Machine concurrently (${runProjectCommand})?`,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcommand: runSmCommand,\n\t\t\t\t\t\tmessage: `Would you like to run Slice Machine (${runSmCommand})?`,\n\t\t\t\t\t};\n\t\t\t\t})();\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: finalSmCommand.message,\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(\n\t\t\t\t\t\tfinalSmCommand.command,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t\t},\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\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\t\t} catch (e) {\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.shortMessage);\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${\n\t\t\t\t\t\t\t\tlogSymbols.error\n\t\t\t\t\t\t\t} Dependency installation failed, try again with:\\n\\n ${chalk.gray(\n\t\t\t\t\t\t\t\t\"$\",\n\t\t\t\t\t\t\t)} ${chalk.cyan(tryAgainCommand)}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.installProcess = execaProcess;\n\n\t\t\t\t\ttask.title = `Began core dependencies installation with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)} ... (running in background)`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected 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 new Promise((resolve) => {\n\t\t\t\t\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\t\t\t\t\tprocess.stdin.resume();\n\t\t\t\t\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\t\t\t\t\tawait this.manager.user.nodeLoginSession({\n\t\t\t\t\t\t\tport,\n\t\t\t\t\t\t\tonListenCallback() {\n\t\t\t\t\t\t\t\topen(url);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tparentTask.output = \"\";\n\t\t\t\t\tparentTask.title = `Logged in`;\n\n\t\t\t\t\treturn listr(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user profile...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\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 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.LessThan4 || validation.MoreThan30) {\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.LessThan4\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"4 characters long or more\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"4 characters long or more\")}`;\n\n\t\t\t\tconst maxRule = validation.MoreThan30\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"30 characters long or less\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"30 characters long or less\")}`;\n\n\t\t\t\tthis.msg = chalk.reset(\n\t\t\t\t\t`\nChoose a name for your Prismic repository\n\n NAMING RULES\n ${minRule}\n ${maxRule}\n 3. Name will be ${chalk.cyan(\"kebab-cased\")} automatically\n\n CONSIDERATIONS\n 1. Once picked, your repository name ${chalk.cyan(\"cannot be changed\")}\n 2. A ${chalk.cyan(\n\t\t\t\"display name\",\n\t\t)} for the repository can be configured later on\n\n PREVIEW\n Dashboard ${chalk.cyan(`https://${domain}.prismic.io`)}\n API ${chalk.cyan(`https://${domain}.cdn.prismic.io/api/v2`)}\n\n${chalk.cyan(\"?\")} Your Prismic repository name`.replace(\"\\n\", \"\"),\n\t\t\t\t);\n\t\t\t},\n\t\t\tvalidate: async (rawDomain: string) => {\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\tdomain,\n\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t});\n\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\tvalidation,\n\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t});\n\n\t\t\t\treturn errorMessage || true;\n\t\t\t},\n\t\t\tformat: (value) => {\n\t\t\t\treturn formatRepositoryDomain(value);\n\t\t\t},\n\t\t});\n\n\t\t// Clear extra lines\n\t\tprocess.stdout.moveCursor?.(0, -16);\n\t\tprocess.stdout.clearScreenDown?.();\n\n\t\tthis.context.repository = {\n\t\t\tdomain,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tprotected createNewRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t);\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Creating new repository ${chalk.cyan(\n\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.title = `Created new repository ${chalk.cyan(\n\t\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected finishCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Finishing core dependencies installation with ${chalk.cyan(\n\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.installProcess,\n\t\t\t\t\t\t\"Initial dependencies installation process must be available through context to run `finishCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst updateOutput = (data: Buffer | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Don't clutter console with logs when process is non TTY (CI, etc.)\n\t\t\t\t\tif (process.stdout.isTTY || process.env.NODE_ENV === \"test\") {\n\t\t\t\t\t\tthis.context.installProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t}\n\t\t\t\t\tthis.context.installProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.context.installProcess;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Error catching happens when then process is started ealier so\n\t\t\t\t\t\t * that all install errors, earlier and presents, can be catched.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * Here, we force the task to wait so that it is neither marked as\n\t\t\t\t\t\t * done or has the opportunity to handle the error itself.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t// If for whatever reason the process is not exited by now, we still throw the error\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 5000));\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Installed core dependencies with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Resolving Slice Machine configuration...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tlet sliceMachineConfigExists = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.manager.project.getSliceMachineConfigPath();\n\t\t\t\t\t\tsliceMachineConfigExists = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// noop, config does not exists, we'll create it\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sliceMachineConfigExists) {\n\t\t\t\t\t\tparentTask.title = \"Updating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst config = await this.manager.project.getSliceMachineConfig();\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tparentTask.title = \"Updated Slice Machine configuration\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentTask.title = \"Creating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst sliceMachineConfigPath =\n\t\t\t\t\t\t\tawait this.manager.project.suggestSliceMachineConfigPath();\n\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\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 pushDataToPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Pushing data to Prismic...\",\n\t\t\t\ttask: (_, parentTask) =>\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing slices...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushSlices) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-slices used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst 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 `pushDataToPrismic`\",\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\tparentTask.title = \"Pushed data to Prismic\";\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\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Cleaning up data push artifacts\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst root = await this.manager.project.getRoot();\n\t\t\t\t\t\t\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait fs.rm(documentsDirectoryPath, {\n\t\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t\t\trecursive: true,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t// Noop, it's not that big of a deal if we cannot delete this directory\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttask.title = \"Cleaned up data push artifacts\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected initializeProject(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Initializing project...\",\n\t\t\t\ttask: async (_, parentTask) =>\n\t\t\t\t\t// We return another Listr instance in the event we have additional task to perform to initialize the project\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: `Patching ${chalk.cyan(\"package.json\")} scripts...`,\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst pkgPath = path.join(this.manager.cwd, \"package.json\");\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst pkgRaw = await fs.readFile(pkgPath, \"utf-8\");\n\t\t\t\t\t\t\t\t\tconst pkg = JSON.parse(pkgRaw);\n\n\t\t\t\t\t\t\t\t\tpkg.scripts ||= {};\n\n\t\t\t\t\t\t\t\t\tif (!pkg.scripts[START_SCRIPT_KEY]) {\n\t\t\t\t\t\t\t\t\t\tpkg.scripts[START_SCRIPT_KEY] = START_SCRIPT_VALUE;\n\n\t\t\t\t\t\t\t\t\t\t// Cheap indent detection based on https://github.com/sindresorhus/detect-indent (simplified because we're only dealing with JSON here)\n\t\t\t\t\t\t\t\t\t\tconst firstIndent = pkgRaw\n\t\t\t\t\t\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t\t\t\t\t\t.find((line) => line.match(/^(?:( )+|\\t+)/));\n\t\t\t\t\t\t\t\t\t\tconst indent = firstIndent?.match(/^(?:( )+|\\t+)/)?.[0];\n\n\t\t\t\t\t\t\t\t\t\tawait fs.writeFile(\n\t\t\t\t\t\t\t\t\t\t\tpkgPath,\n\t\t\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\t\t\tpkg,\n\t\t\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\t\t\tindent && indent !== \" \" ? indent : \" \",\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t!pkg.scripts[\"slicemachine\"].startsWith(START_SCRIPT_VALUE)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Script already exists\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\ttask.title = `Could not patch ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t\t)} scripts (warning)`;\n\t\t\t\t\t\t\t\t\tparentTask.title = `Initialized project (could not patch ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t\t)} scripts)`;\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tthis.context.projectInitialization ||= {};\n\t\t\t\t\t\t\t\tthis.context.projectInitialization.patchedScript = true;\n\n\t\t\t\t\t\t\t\ttask.title = `Patched ${chalk.cyan(\"package.json\")} scripts`;\n\t\t\t\t\t\t\t\tparentTask.title = `Initialized project (patched ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t)} scripts)`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected initializePlugins(): Promise<void> {\n\t\treturn listrRun(\n\t\t\t[\n\t\t\t\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","path","fs","execaCommand","listrRun","downloadTemplate","GIGET_PROVIDER","GIGET_ORGANIZATION","getRandomRepositoryDomain","listr","_","detectFramework","detectStarterId","_b","_a","formatRepositoryDomain","validateRepositoryDomainAndAvailability","domain","getErrorMessageForRepositoryDomainValidation","validateRepositoryDomain","maybeSuggestion","globby","SLICE_MACHINE_INIT_USER_AGENT","START_SCRIPT_KEY","START_SCRIPT_VALUE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,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;AAmPA,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;AAAA,Q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1B,WAAOpB,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;;;"}
@@ -62,7 +62,7 @@ export declare class SliceMachineInitProcess {
62
62
  documents: string[];
63
63
  directoryPath: string;
64
64
  } | undefined>;
65
- protected syncDataWithPrismic(): Promise<void>;
65
+ protected pushDataToPrismic(): Promise<void>;
66
66
  protected initializeProject(): Promise<void>;
67
67
  protected initializePlugins(): Promise<void>;
68
68
  }
@@ -117,7 +117,7 @@ ${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} In
117
117
  if (!this.context.repository.exists) {
118
118
  await this.createNewRepository();
119
119
  }
120
- await this.syncDataWithPrismic();
120
+ await this.pushDataToPrismic();
121
121
  await this.initializeProject();
122
122
  await this.initializePlugins();
123
123
  } catch (error) {
@@ -220,9 +220,6 @@ ${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim("→")} I
220
220
  if (slices.length > 0 || ctLibrary.ids.length > 0 || documentsGlob !== void 0 && documentsGlob.documents.length > 0) {
221
221
  return true;
222
222
  }
223
- if (ctLibrary.ids.length === 0) {
224
- return true;
225
- }
226
223
  } catch (e) {
227
224
  return true;
228
225
  }
@@ -727,10 +724,10 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
727
724
  });
728
725
  return { signature, documents, directoryPath: documentsDirectoryPath };
729
726
  }
730
- syncDataWithPrismic() {
727
+ pushDataToPrismic() {
731
728
  return listrRun([
732
729
  {
733
- title: "Syncing data with Prismic...",
730
+ title: "Pushing data to Prismic...",
734
731
  task: (_, parentTask) => listr([
735
732
  {
736
733
  title: "Pushing slices...",
@@ -803,10 +800,11 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
803
800
  }
804
801
  },
805
802
  task: async (_2, task) => {
806
- assertExists(this.context.repository, "Repository selection must be available through context to run `syncDataWithPrismic`");
803
+ assertExists(this.context.repository, "Repository selection must be available through context to run `pushDataToPrismic`");
807
804
  try {
808
805
  const documentsRead = await this.readDocuments();
809
806
  if (documentsRead === void 0 || documentsRead.documents.length === 0) {
807
+ parentTask.title = "Pushed data to Prismic";
810
808
  task.skip("No document to push");
811
809
  return;
812
810
  }
@@ -828,7 +826,9 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
828
826
  signature
829
827
  });
830
828
  task.title = "Pushed all documents";
829
+ parentTask.title = "Pushed data to Prismic";
831
830
  } catch {
831
+ parentTask.title = "Pushed data to Prismic";
832
832
  task.skip("No document to push");
833
833
  return;
834
834
  }
@@ -847,26 +847,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""));
847
847
  } catch {
848
848
  }
849
849
  task.title = "Cleaned up data push artifacts";
850
- }
851
- },
852
- {
853
- title: "Pulling existing types...",
854
- task: async (_2, task) => {
855
- const { ids, errors } = await this.manager.customTypes.readCustomTypeLibrary();
856
- if (errors.length > 0) {
857
- throw new Error(`Failed to read custom type libraries: ${errors.join(", ")}`);
858
- }
859
- if (ids && ids.length > 0) {
860
- task.skip("Types already exists");
861
- parentTask.title = "Synced data with Prismic";
862
- return;
863
- }
864
- const remoteTypes = await this.manager.customTypes.fetchRemoteCustomTypes();
865
- await Promise.all(remoteTypes.map(async (model) => {
866
- await this.manager.customTypes.createCustomType({ model });
867
- }));
868
- task.title = "Pulled existing types";
869
- parentTask.title = "Synced data with Prismic";
850
+ parentTask.title = "Pushed data to Prismic";
870
851
  }
871
852
  }
872
853
  ])
@@ -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} 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);\n\n\t\ttry {\n\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t })\n\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t });\n\n\t\t\tconst runProjectCommand = await getRunScriptCommand({\n\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\tscript: \"dev\",\n\t\t\t});\n\n\t\t\tconst apiEndpoints = this.manager.getAPIEndpoints();\n\t\t\tconst wroomHost = new URL(apiEndpoints.PrismicWroom).host;\n\n\t\t\tconst dashboardURL = new URL(\n\t\t\t\t`https://${this.context.repository.domain}.${wroomHost}`,\n\t\t\t)\n\t\t\t\t.toString()\n\t\t\t\t.replace(/\\/$/, \"\");\n\t\t\tconst apiURL = new URL(\n\t\t\t\t\"./api/v2\",\n\t\t\t\t`https://${this.context.repository.domain}.cdn.${wroomHost}`,\n\t\t\t).toString();\n\n\t\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`\n YOUR REPOSITORY\n Page Builder ${chalk.cyan(dashboardURL)}\n API ${chalk.cyan(apiURL)}\n\n RESOURCES\n Documentation ${chalk.cyan(\n\t\t\tthis.context.framework.prismicDocumentation,\n\t\t)}\n Getting help ${chalk.cyan(\"https://community.prismic.io\")}\n\n GETTING STARTED\n Run Slice Machine ${chalk.cyan(runSmCommand)}\n Run your project ${chalk.cyan(runProjectCommand)}\n\t`);\n\n\t\t\tif (this.options.starter && this.options.repository) {\n\t\t\t\tconst { openDashboard } = await prompt<boolean, \"openDashboard\">({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"openDashboard\",\n\t\t\t\t\tmessage: \"Would you like to open your repository?\",\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (openDashboard) {\n\t\t\t\t\topen(dashboardURL);\n\t\t\t\t}\n\t\t\t} else if (this.options.startSlicemachine) {\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\t\t\t\tconst scripts = pkg.scripts || {};\n\n\t\t\t\tconst finalSmCommand = (() => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tscripts[\"dev\"] &&\n\t\t\t\t\t\ttypeof scripts[\"dev\"] === \"string\" &&\n\t\t\t\t\t\tscripts[\"dev\"].includes(\":slicemachine\")\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcommand: runProjectCommand,\n\t\t\t\t\t\t\tmessage: `Would you like to run your project and Slice Machine concurrently (${runProjectCommand})?`,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcommand: runSmCommand,\n\t\t\t\t\t\tmessage: `Would you like to run Slice Machine (${runSmCommand})?`,\n\t\t\t\t\t};\n\t\t\t\t})();\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: finalSmCommand.message,\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(\n\t\t\t\t\t\tfinalSmCommand.command,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t\t},\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 (e) {\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.shortMessage);\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${\n\t\t\t\t\t\t\t\tlogSymbols.error\n\t\t\t\t\t\t\t} Dependency installation failed, try again with:\\n\\n ${chalk.gray(\n\t\t\t\t\t\t\t\t\"$\",\n\t\t\t\t\t\t\t)} ${chalk.cyan(tryAgainCommand)}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.installProcess = execaProcess;\n\n\t\t\t\t\ttask.title = `Began core dependencies installation with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)} ... (running in background)`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected 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 new Promise((resolve) => {\n\t\t\t\t\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\t\t\t\t\tprocess.stdin.resume();\n\t\t\t\t\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\t\t\t\t\tawait this.manager.user.nodeLoginSession({\n\t\t\t\t\t\t\tport,\n\t\t\t\t\t\t\tonListenCallback() {\n\t\t\t\t\t\t\t\topen(url);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tparentTask.output = \"\";\n\t\t\t\t\tparentTask.title = `Logged in`;\n\n\t\t\t\t\treturn listr(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user profile...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\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 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.LessThan4 || validation.MoreThan30) {\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.LessThan4\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"4 characters long or more\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"4 characters long or more\")}`;\n\n\t\t\t\tconst maxRule = validation.MoreThan30\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"30 characters long or less\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"30 characters long or less\")}`;\n\n\t\t\t\tthis.msg = chalk.reset(\n\t\t\t\t\t`\nChoose a name for your Prismic repository\n\n NAMING RULES\n ${minRule}\n ${maxRule}\n 3. Name will be ${chalk.cyan(\"kebab-cased\")} automatically\n\n CONSIDERATIONS\n 1. Once picked, your repository name ${chalk.cyan(\"cannot be changed\")}\n 2. A ${chalk.cyan(\n\t\t\t\"display name\",\n\t\t)} for the repository can be configured later on\n\n PREVIEW\n Dashboard ${chalk.cyan(`https://${domain}.prismic.io`)}\n API ${chalk.cyan(`https://${domain}.cdn.prismic.io/api/v2`)}\n\n${chalk.cyan(\"?\")} Your Prismic repository name`.replace(\"\\n\", \"\"),\n\t\t\t\t);\n\t\t\t},\n\t\t\tvalidate: async (rawDomain: string) => {\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\tdomain,\n\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t});\n\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\tvalidation,\n\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t});\n\n\t\t\t\treturn errorMessage || true;\n\t\t\t},\n\t\t\tformat: (value) => {\n\t\t\t\treturn formatRepositoryDomain(value);\n\t\t\t},\n\t\t});\n\n\t\t// Clear extra lines\n\t\tprocess.stdout.moveCursor?.(0, -16);\n\t\tprocess.stdout.clearScreenDown?.();\n\n\t\tthis.context.repository = {\n\t\t\tdomain,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tprotected createNewRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t);\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Creating new repository ${chalk.cyan(\n\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.title = `Created new repository ${chalk.cyan(\n\t\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected finishCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Finishing core dependencies installation with ${chalk.cyan(\n\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.installProcess,\n\t\t\t\t\t\t\"Initial dependencies installation process must be available through context to run `finishCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst updateOutput = (data: Buffer | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Don't clutter console with logs when process is non TTY (CI, etc.)\n\t\t\t\t\tif (process.stdout.isTTY || process.env.NODE_ENV === \"test\") {\n\t\t\t\t\t\tthis.context.installProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t}\n\t\t\t\t\tthis.context.installProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.context.installProcess;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Error catching happens when then process is started ealier so\n\t\t\t\t\t\t * that all install errors, earlier and presents, can be catched.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * Here, we force the task to wait so that it is neither marked as\n\t\t\t\t\t\t * done or has the opportunity to handle the error itself.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t// If for whatever reason the process is not exited by now, we still throw the error\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 5000));\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Installed core dependencies with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Resolving Slice Machine configuration...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tlet sliceMachineConfigExists = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.manager.project.getSliceMachineConfigPath();\n\t\t\t\t\t\tsliceMachineConfigExists = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// noop, config does not exists, we'll create it\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sliceMachineConfigExists) {\n\t\t\t\t\t\tparentTask.title = \"Updating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst config = await this.manager.project.getSliceMachineConfig();\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tparentTask.title = \"Updated Slice Machine configuration\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentTask.title = \"Creating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst sliceMachineConfigPath =\n\t\t\t\t\t\t\tawait this.manager.project.suggestSliceMachineConfigPath();\n\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\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 exists\");\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":["pkg","_","_b","_a","domain","maybeSuggestion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,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;AA0PA,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;AAAA,QACT,OAAO;AAAA,MAAA,CACP;AAAA,IAAA;AAGQ,4CAAmB,OAAO,UAA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;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\";\n\nimport {\n\tcreateSliceMachineManager,\n\tPrismicUserProfile,\n\tPrismicRepository,\n\tSliceMachineManager,\n\tPackageManager,\n\tStarterId,\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.pushDataToPrismic();\n\t\t\tawait this.initializeProject();\n\t\t\tawait this.initializePlugins();\n\t\t} catch (error) {\n\t\t\tawait this.trackError(error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tawait this.manager.telemetry.track({\n\t\t\tevent: \"command:init:end\",\n\t\t\tframework: this.context.framework.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);\n\n\t\ttry {\n\t\t\tconst runSmCommand = this.context.projectInitialization?.patchedScript\n\t\t\t\t? await getRunScriptCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"slicemachine\",\n\t\t\t\t })\n\t\t\t\t: await getExecuteCommand({\n\t\t\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\t\t\tscript: \"start-slicemachine\",\n\t\t\t\t });\n\n\t\t\tconst runProjectCommand = await getRunScriptCommand({\n\t\t\t\tagent: this.context.packageManager || \"npm\",\n\t\t\t\tscript: \"dev\",\n\t\t\t});\n\n\t\t\tconst apiEndpoints = this.manager.getAPIEndpoints();\n\t\t\tconst wroomHost = new URL(apiEndpoints.PrismicWroom).host;\n\n\t\t\tconst dashboardURL = new URL(\n\t\t\t\t`https://${this.context.repository.domain}.${wroomHost}`,\n\t\t\t)\n\t\t\t\t.toString()\n\t\t\t\t.replace(/\\/$/, \"\");\n\t\t\tconst apiURL = new URL(\n\t\t\t\t\"./api/v2\",\n\t\t\t\t`https://${this.context.repository.domain}.cdn.${wroomHost}`,\n\t\t\t).toString();\n\n\t\t\t// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`\n YOUR REPOSITORY\n Page Builder ${chalk.cyan(dashboardURL)}\n API ${chalk.cyan(apiURL)}\n\n RESOURCES\n Documentation ${chalk.cyan(\n\t\t\tthis.context.framework.prismicDocumentation,\n\t\t)}\n Getting help ${chalk.cyan(\"https://community.prismic.io\")}\n\n GETTING STARTED\n Run Slice Machine ${chalk.cyan(runSmCommand)}\n Run your project ${chalk.cyan(runProjectCommand)}\n\t`);\n\n\t\t\tif (this.options.starter && this.options.repository) {\n\t\t\t\tconst { openDashboard } = await prompt<boolean, \"openDashboard\">({\n\t\t\t\t\ttype: \"confirm\",\n\t\t\t\t\tname: \"openDashboard\",\n\t\t\t\t\tmessage: \"Would you like to open your repository?\",\n\t\t\t\t\tinitial: true,\n\t\t\t\t});\n\n\t\t\t\tif (openDashboard) {\n\t\t\t\t\topen(dashboardURL);\n\t\t\t\t}\n\t\t\t} else if (this.options.startSlicemachine) {\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\t\t\t\tconst scripts = pkg.scripts || {};\n\n\t\t\t\tconst finalSmCommand = (() => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tscripts[\"dev\"] &&\n\t\t\t\t\t\ttypeof scripts[\"dev\"] === \"string\" &&\n\t\t\t\t\t\tscripts[\"dev\"].includes(\":slicemachine\")\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcommand: runProjectCommand,\n\t\t\t\t\t\t\tmessage: `Would you like to run your project and Slice Machine concurrently (${runProjectCommand})?`,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcommand: runSmCommand,\n\t\t\t\t\t\tmessage: `Would you like to run Slice Machine (${runSmCommand})?`,\n\t\t\t\t\t};\n\t\t\t\t})();\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: finalSmCommand.message,\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(\n\t\t\t\t\t\tfinalSmCommand.command,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tenv: { FORCE_COLOR: \"true\" },\n\t\t\t\t\t\t},\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\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\t\t} catch (e) {\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.shortMessage);\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`\\n\\n${error.shortMessage}\\n${error.stderr}\\n\\n${\n\t\t\t\t\t\t\t\tlogSymbols.error\n\t\t\t\t\t\t\t} Dependency installation failed, try again with:\\n\\n ${chalk.gray(\n\t\t\t\t\t\t\t\t\"$\",\n\t\t\t\t\t\t\t)} ${chalk.cyan(tryAgainCommand)}`,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.installProcess = execaProcess;\n\n\t\t\t\t\ttask.title = `Began core dependencies installation with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)} ... (running in background)`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected 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 new Promise((resolve) => {\n\t\t\t\t\t\t\tconst initialRawMode = !!process.stdin.isRaw;\n\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(true);\n\t\t\t\t\t\t\tprocess.stdin.resume();\n\t\t\t\t\t\t\tprocess.stdin.once(\"data\", (data: Buffer) => {\n\t\t\t\t\t\t\t\tprocess.stdin.setRawMode?.(initialRawMode);\n\t\t\t\t\t\t\t\tprocess.stdin.pause();\n\t\t\t\t\t\t\t\tresolve(data.toString(\"utf-8\"));\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tparentTask.output = \"Browser opened, waiting for you to login...\";\n\t\t\t\t\t\tconst { port, url } = await this.manager.user.getLoginSessionInfo();\n\t\t\t\t\t\tawait this.manager.user.nodeLoginSession({\n\t\t\t\t\t\t\tport,\n\t\t\t\t\t\t\tonListenCallback() {\n\t\t\t\t\t\t\t\topen(url);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tparentTask.output = \"\";\n\t\t\t\t\tparentTask.title = `Logged in`;\n\n\t\t\t\t\treturn listr(\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttitle: \"Fetching user profile...\",\n\t\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\t\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 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.LessThan4 || validation.MoreThan30) {\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.LessThan4\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"4 characters long or more\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"4 characters long or more\")}`;\n\n\t\t\t\tconst maxRule = validation.MoreThan30\n\t\t\t\t\t? chalk.red(\n\t\t\t\t\t\t\t`1. Name must be ${chalk.bold(\"30 characters long or less\")}`,\n\t\t\t\t\t )\n\t\t\t\t\t: `1. Name must be ${chalk.cyan(\"30 characters long or less\")}`;\n\n\t\t\t\tthis.msg = chalk.reset(\n\t\t\t\t\t`\nChoose a name for your Prismic repository\n\n NAMING RULES\n ${minRule}\n ${maxRule}\n 3. Name will be ${chalk.cyan(\"kebab-cased\")} automatically\n\n CONSIDERATIONS\n 1. Once picked, your repository name ${chalk.cyan(\"cannot be changed\")}\n 2. A ${chalk.cyan(\n\t\t\t\"display name\",\n\t\t)} for the repository can be configured later on\n\n PREVIEW\n Dashboard ${chalk.cyan(`https://${domain}.prismic.io`)}\n API ${chalk.cyan(`https://${domain}.cdn.prismic.io/api/v2`)}\n\n${chalk.cyan(\"?\")} Your Prismic repository name`.replace(\"\\n\", \"\"),\n\t\t\t\t);\n\t\t\t},\n\t\t\tvalidate: async (rawDomain: string) => {\n\t\t\t\tconst domain = formatRepositoryDomain(rawDomain);\n\t\t\t\tconst validation = await validateRepositoryDomainAndAvailability({\n\t\t\t\t\tdomain,\n\t\t\t\t\texistsFn: (domain) =>\n\t\t\t\t\t\tthis.manager.prismicRepository.checkExists({ domain }),\n\t\t\t\t});\n\t\t\t\tconst errorMessage = getErrorMessageForRepositoryDomainValidation({\n\t\t\t\t\tvalidation,\n\t\t\t\t\tdisplayDomain: chalk.cyan(domain),\n\t\t\t\t});\n\n\t\t\t\treturn errorMessage || true;\n\t\t\t},\n\t\t\tformat: (value) => {\n\t\t\t\treturn formatRepositoryDomain(value);\n\t\t\t},\n\t\t});\n\n\t\t// Clear extra lines\n\t\tprocess.stdout.moveCursor?.(0, -16);\n\t\tprocess.stdout.clearScreenDown?.();\n\n\t\tthis.context.repository = {\n\t\t\tdomain,\n\t\t\texists: false,\n\t\t};\n\t}\n\n\tprotected createNewRepository(): Promise<void> {\n\t\tassertExists(\n\t\t\tthis.context.repository,\n\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t);\n\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Creating new repository ${chalk.cyan(\n\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `createNewRepository`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tawait this.manager.prismicRepository.create({\n\t\t\t\t\t\tdomain: this.context.repository.domain,\n\t\t\t\t\t\tframework: this.context.framework.wroomTelemetryID,\n\t\t\t\t\t\tstarterId: this.context.starterId,\n\t\t\t\t\t});\n\n\t\t\t\t\tthis.context.repository.exists = true;\n\t\t\t\t\ttask.title = `Created new repository ${chalk.cyan(\n\t\t\t\t\t\tthis.context.repository.domain,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected finishCoreDependenciesInstallation(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: `Finishing core dependencies installation with ${chalk.cyan(\n\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t)} ...`,\n\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.installProcess,\n\t\t\t\t\t\t\"Initial dependencies installation process must be available through context to run `finishCoreDependenciesInstallation`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tconst updateOutput = (data: Buffer | null) => {\n\t\t\t\t\t\tif (data instanceof Buffer) {\n\t\t\t\t\t\t\ttask.output = data.toString();\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t\t// Don't clutter console with logs when process is non TTY (CI, etc.)\n\t\t\t\t\tif (process.stdout.isTTY || process.env.NODE_ENV === \"test\") {\n\t\t\t\t\t\tthis.context.installProcess.stdout?.on(\"data\", updateOutput);\n\t\t\t\t\t}\n\t\t\t\t\tthis.context.installProcess.stderr?.on(\"data\", updateOutput);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.context.installProcess;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * Error catching happens when then process is started ealier so\n\t\t\t\t\t\t * that all install errors, earlier and presents, can be catched.\n\t\t\t\t\t\t *\n\t\t\t\t\t\t * Here, we force the task to wait so that it is neither marked as\n\t\t\t\t\t\t * done or has the opportunity to handle the error itself.\n\t\t\t\t\t\t */\n\t\t\t\t\t\t// If for whatever reason the process is not exited by now, we still throw the error\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 5000));\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\n\t\t\t\t\ttask.title = `Installed core dependencies with ${chalk.cyan(\n\t\t\t\t\t\tthis.context.packageManager,\n\t\t\t\t\t)}`;\n\t\t\t\t},\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected upsertSliceMachineConfigurationAndStartPluginRunner(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Resolving Slice Machine configuration...\",\n\t\t\t\ttask: async (_, parentTask) => {\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.framework,\n\t\t\t\t\t\t\"Project framework must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\t\t\t\t\tassertExists(\n\t\t\t\t\t\tthis.context.repository,\n\t\t\t\t\t\t\"Repository selection must be available through context to run `upsertSliceMachineConfiguration`\",\n\t\t\t\t\t);\n\n\t\t\t\t\tlet sliceMachineConfigExists = false;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this.manager.project.getSliceMachineConfigPath();\n\t\t\t\t\t\tsliceMachineConfigExists = true;\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// noop, config does not exists, we'll create it\n\t\t\t\t\t}\n\n\t\t\t\t\tif (sliceMachineConfigExists) {\n\t\t\t\t\t\tparentTask.title = \"Updating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst config = await this.manager.project.getSliceMachineConfig();\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\t...config,\n\t\t\t\t\t\t\t\trepositoryName: this.context.repository.domain,\n\t\t\t\t\t\t\t\tadapter: this.context.framework.adapterName,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tparentTask.title = \"Updated Slice Machine configuration\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tparentTask.title = \"Creating Slice Machine configuration...\";\n\n\t\t\t\t\t\tconst sliceMachineConfigPath =\n\t\t\t\t\t\t\tawait this.manager.project.suggestSliceMachineConfigPath();\n\n\t\t\t\t\t\tawait this.manager.project.writeSliceMachineConfig({\n\t\t\t\t\t\t\tconfig: {\n\t\t\t\t\t\t\t\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 pushDataToPrismic(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Pushing data to Prismic...\",\n\t\t\t\ttask: (_, parentTask) =>\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Pushing slices...\",\n\t\t\t\t\t\t\tskip: () => {\n\t\t\t\t\t\t\t\tif (!this.options.push) {\n\t\t\t\t\t\t\t\t\treturn `--no-push used`;\n\t\t\t\t\t\t\t\t} else if (!this.options.pushSlices) {\n\t\t\t\t\t\t\t\t\treturn `--no-push-slices used`;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst 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 `pushDataToPrismic`\",\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\tparentTask.title = \"Pushed data to Prismic\";\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\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t\t\ttask.skip(\"No document to push\");\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: \"Cleaning up data push artifacts\",\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst root = await this.manager.project.getRoot();\n\t\t\t\t\t\t\t\tconst documentsDirectoryPath = path.resolve(root, \"documents\");\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tawait fs.rm(documentsDirectoryPath, {\n\t\t\t\t\t\t\t\t\t\tforce: true,\n\t\t\t\t\t\t\t\t\t\trecursive: true,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\t\t// Noop, it's not that big of a deal if we cannot delete this directory\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttask.title = \"Cleaned up data push artifacts\";\n\t\t\t\t\t\t\t\tparentTask.title = \"Pushed data to Prismic\";\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected initializeProject(): Promise<void> {\n\t\treturn listrRun([\n\t\t\t{\n\t\t\t\ttitle: \"Initializing project...\",\n\t\t\t\ttask: async (_, parentTask) =>\n\t\t\t\t\t// We return another Listr instance in the event we have additional task to perform to initialize the project\n\t\t\t\t\tlistr([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttitle: `Patching ${chalk.cyan(\"package.json\")} scripts...`,\n\t\t\t\t\t\t\ttask: async (_, task) => {\n\t\t\t\t\t\t\t\tconst pkgPath = path.join(this.manager.cwd, \"package.json\");\n\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tconst pkgRaw = await fs.readFile(pkgPath, \"utf-8\");\n\t\t\t\t\t\t\t\t\tconst pkg = JSON.parse(pkgRaw);\n\n\t\t\t\t\t\t\t\t\tpkg.scripts ||= {};\n\n\t\t\t\t\t\t\t\t\tif (!pkg.scripts[START_SCRIPT_KEY]) {\n\t\t\t\t\t\t\t\t\t\tpkg.scripts[START_SCRIPT_KEY] = START_SCRIPT_VALUE;\n\n\t\t\t\t\t\t\t\t\t\t// Cheap indent detection based on https://github.com/sindresorhus/detect-indent (simplified because we're only dealing with JSON here)\n\t\t\t\t\t\t\t\t\t\tconst firstIndent = pkgRaw\n\t\t\t\t\t\t\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t\t\t\t\t\t\t.find((line) => line.match(/^(?:( )+|\\t+)/));\n\t\t\t\t\t\t\t\t\t\tconst indent = firstIndent?.match(/^(?:( )+|\\t+)/)?.[0];\n\n\t\t\t\t\t\t\t\t\t\tawait fs.writeFile(\n\t\t\t\t\t\t\t\t\t\t\tpkgPath,\n\t\t\t\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\t\t\t\tpkg,\n\t\t\t\t\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\t\t\t\t\tindent && indent !== \" \" ? indent : \" \",\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\t\t\t!pkg.scripts[\"slicemachine\"].startsWith(START_SCRIPT_VALUE)\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tthrow new Error(\"Script already exists\");\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\t\ttask.title = `Could not patch ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t\t)} scripts (warning)`;\n\t\t\t\t\t\t\t\t\tparentTask.title = `Initialized project (could not patch ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t\t)} scripts)`;\n\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tthis.context.projectInitialization ||= {};\n\t\t\t\t\t\t\t\tthis.context.projectInitialization.patchedScript = true;\n\n\t\t\t\t\t\t\t\ttask.title = `Patched ${chalk.cyan(\"package.json\")} scripts`;\n\t\t\t\t\t\t\t\tparentTask.title = `Initialized project (patched ${chalk.cyan(\n\t\t\t\t\t\t\t\t\t\"package.json\",\n\t\t\t\t\t\t\t\t)} scripts)`;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t},\n\t\t]);\n\t}\n\n\tprotected initializePlugins(): Promise<void> {\n\t\treturn listrRun(\n\t\t\t[\n\t\t\t\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":["pkg","_","_b","_a","domain","maybeSuggestion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;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AAClC,qBAAA,QAAQ,sBAAsB,gBAAgB;AAEnD,qBAAK,QAAQ,WAAW,MAAM,KAAK,cAAc;AACjD,2BAAW,QAAQ,gCAAgC,MAAM,KACxD,cAAc;AAAA,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,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.7.2-dev-upgrade-legacy.1";
4
+ const version = "2.7.2-dev-next-release.0";
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.12.1-dev-upgrade-legacy.1",
58
+ "@slicemachine/manager": "^0.12.1-dev-next-release.0",
59
59
  chalk: "^4.1.2",
60
60
  giget: "^1.1.2",
61
61
  globby: "^13.1.3",
@@ -68,7 +68,7 @@ const dependencies = {
68
68
  };
69
69
  const devDependencies = {
70
70
  "@size-limit/preset-small-lib": "8.2.4",
71
- "@slicemachine/plugin-kit": "0.4.19-dev-upgrade-legacy.1",
71
+ "@slicemachine/plugin-kit": "0.4.19-dev-next-release.0",
72
72
  "@types/listr": "0.14.4",
73
73
  "@types/prompts": "2.4.3",
74
74
  "@types/semver": "7.3.13",
@@ -94,7 +94,7 @@ const devDependencies = {
94
94
  "vite-plugin-sdk": "0.1.1",
95
95
  vitest: "0.32.0"
96
96
  };
97
- const gitHead = "541c79856860e268caab22fd8363eea18b788c34";
97
+ const gitHead = "924c533c0ca647203f78794eef82d30d2b2644fa";
98
98
  const pkg = {
99
99
  name,
100
100
  version,
@@ -1,5 +1,5 @@
1
1
  const name = "@slicemachine/init";
2
- const version = "2.7.2-dev-upgrade-legacy.1";
2
+ const version = "2.7.2-dev-next-release.0";
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.12.1-dev-upgrade-legacy.1",
56
+ "@slicemachine/manager": "^0.12.1-dev-next-release.0",
57
57
  chalk: "^4.1.2",
58
58
  giget: "^1.1.2",
59
59
  globby: "^13.1.3",
@@ -66,7 +66,7 @@ const dependencies = {
66
66
  };
67
67
  const devDependencies = {
68
68
  "@size-limit/preset-small-lib": "8.2.4",
69
- "@slicemachine/plugin-kit": "0.4.19-dev-upgrade-legacy.1",
69
+ "@slicemachine/plugin-kit": "0.4.19-dev-next-release.0",
70
70
  "@types/listr": "0.14.4",
71
71
  "@types/prompts": "2.4.3",
72
72
  "@types/semver": "7.3.13",
@@ -92,7 +92,7 @@ const devDependencies = {
92
92
  "vite-plugin-sdk": "0.1.1",
93
93
  vitest: "0.32.0"
94
94
  };
95
- const gitHead = "541c79856860e268caab22fd8363eea18b788c34";
95
+ const gitHead = "924c533c0ca647203f78794eef82d30d2b2644fa";
96
96
  const pkg = {
97
97
  name,
98
98
  version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/init",
3
- "version": "2.7.2-dev-upgrade-legacy.1",
3
+ "version": "2.7.2-dev-next-release.0",
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.12.1-dev-upgrade-legacy.1",
57
+ "@slicemachine/manager": "^0.12.1-dev-next-release.0",
58
58
  "chalk": "^4.1.2",
59
59
  "giget": "^1.1.2",
60
60
  "globby": "^13.1.3",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "devDependencies": {
69
69
  "@size-limit/preset-small-lib": "8.2.4",
70
- "@slicemachine/plugin-kit": "0.4.19-dev-upgrade-legacy.1",
70
+ "@slicemachine/plugin-kit": "0.4.19-dev-next-release.0",
71
71
  "@types/listr": "0.14.4",
72
72
  "@types/prompts": "2.4.3",
73
73
  "@types/semver": "7.3.13",
@@ -93,5 +93,5 @@
93
93
  "vite-plugin-sdk": "0.1.1",
94
94
  "vitest": "0.32.0"
95
95
  },
96
- "gitHead": "541c79856860e268caab22fd8363eea18b788c34"
96
+ "gitHead": "924c533c0ca647203f78794eef82d30d2b2644fa"
97
97
  }
@@ -176,7 +176,7 @@ export class SliceMachineInitProcess {
176
176
  await this.createNewRepository();
177
177
  }
178
178
 
179
- await this.syncDataWithPrismic();
179
+ await this.pushDataToPrismic();
180
180
  await this.initializeProject();
181
181
  await this.initializePlugins();
182
182
  } catch (error) {
@@ -320,8 +320,6 @@ export class SliceMachineInitProcess {
320
320
  this.manager.customTypes.readCustomTypeLibrary(),
321
321
  this.readDocuments(),
322
322
  ]);
323
-
324
- // If repository exists, and there's anything to push
325
323
  if (
326
324
  slices.length > 0 ||
327
325
  ctLibrary.ids.length > 0 ||
@@ -329,11 +327,6 @@ export class SliceMachineInitProcess {
329
327
  ) {
330
328
  return true;
331
329
  }
332
-
333
- // If repository exists, and there might be things to pull
334
- if (ctLibrary.ids.length === 0) {
335
- return true;
336
- }
337
330
  } catch (e) {
338
331
  return true;
339
332
  }
@@ -1117,10 +1110,10 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1117
1110
  return { signature, documents, directoryPath: documentsDirectoryPath };
1118
1111
  }
1119
1112
 
1120
- protected syncDataWithPrismic(): Promise<void> {
1113
+ protected pushDataToPrismic(): Promise<void> {
1121
1114
  return listrRun([
1122
1115
  {
1123
- title: "Syncing data with Prismic...",
1116
+ title: "Pushing data to Prismic...",
1124
1117
  task: (_, parentTask) =>
1125
1118
  listr([
1126
1119
  {
@@ -1216,7 +1209,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1216
1209
  task: async (_, task) => {
1217
1210
  assertExists(
1218
1211
  this.context.repository,
1219
- "Repository selection must be available through context to run `syncDataWithPrismic`",
1212
+ "Repository selection must be available through context to run `pushDataToPrismic`",
1220
1213
  );
1221
1214
 
1222
1215
  try {
@@ -1226,6 +1219,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1226
1219
  documentsRead === undefined ||
1227
1220
  documentsRead.documents.length === 0
1228
1221
  ) {
1222
+ parentTask.title = "Pushed data to Prismic";
1229
1223
  task.skip("No document to push");
1230
1224
 
1231
1225
  return;
@@ -1267,7 +1261,9 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1267
1261
  });
1268
1262
 
1269
1263
  task.title = "Pushed all documents";
1264
+ parentTask.title = "Pushed data to Prismic";
1270
1265
  } catch {
1266
+ parentTask.title = "Pushed data to Prismic";
1271
1267
  task.skip("No document to push");
1272
1268
 
1273
1269
  return;
@@ -1289,41 +1285,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
1289
1285
  }
1290
1286
 
1291
1287
  task.title = "Cleaned up data push artifacts";
1292
- },
1293
- },
1294
- {
1295
- title: "Pulling existing types...",
1296
- task: async (_, task) => {
1297
- const { ids, errors } =
1298
- await this.manager.customTypes.readCustomTypeLibrary();
1299
-
1300
- if (errors.length > 0) {
1301
- // TODO: Provide better error message.
1302
- throw new Error(
1303
- `Failed to read custom type libraries: ${errors.join(
1304
- ", ",
1305
- )}`,
1306
- );
1307
- }
1308
-
1309
- if (ids && ids.length > 0) {
1310
- task.skip("Types already exists");
1311
- parentTask.title = "Synced data with Prismic";
1312
-
1313
- return;
1314
- }
1315
-
1316
- const remoteTypes =
1317
- await this.manager.customTypes.fetchRemoteCustomTypes();
1318
-
1319
- await Promise.all(
1320
- remoteTypes.map(async (model) => {
1321
- await this.manager.customTypes.createCustomType({ model });
1322
- }),
1323
- );
1324
-
1325
- task.title = "Pulled existing types";
1326
- parentTask.title = "Synced data with Prismic";
1288
+ parentTask.title = "Pushed data to Prismic";
1327
1289
  },
1328
1290
  },
1329
1291
  ]),