From 7cb42714008bb78028bc3319271d83f275ca9546 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 23 Aug 2023 15:12:48 +0200 Subject: [PATCH 1/8] feat(init): Add starter download in the init (#1107) --- packages/init/package.json | 1 + packages/init/src/SliceMachineInitProcess.ts | 160 +++++++++++++----- packages/init/src/cli.ts | 24 ++- packages/init/src/constants.ts | 2 + ...achineInitProcess-selectRepository.test.ts | 10 +- yarn.lock | 1 + 6 files changed, 148 insertions(+), 50 deletions(-) diff --git a/packages/init/package.json b/packages/init/package.json index 54d35aeec3..e00dc74efa 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -55,6 +55,7 @@ "@lihbr/listr-update-renderer": "^0.5.3", "@slicemachine/manager": "workspace:^", "chalk": "^4.1.2", + "giget": "^1.1.2", "globby": "^13.1.3", "listr": "^0.14.3", "log-symbols": "^4.1.0", diff --git a/packages/init/src/SliceMachineInitProcess.ts b/packages/init/src/SliceMachineInitProcess.ts index 5938404088..25fb434cd7 100644 --- a/packages/init/src/SliceMachineInitProcess.ts +++ b/packages/init/src/SliceMachineInitProcess.ts @@ -8,6 +8,7 @@ import { execaCommand, type ExecaChildProcess } from "execa"; import open from "open"; import logSymbols from "log-symbols"; import { globby } from "globby"; +import { downloadTemplate } from "giget"; import { createSliceMachineManager, @@ -32,11 +33,18 @@ import { import { listr, listrRun } from "./lib/listr"; import { prompt } from "./lib/prompt"; import { assertExists } from "./lib/assertExists"; -import { START_SCRIPT_KEY, START_SCRIPT_VALUE } from "./constants"; +import { + GIGET_ORGANIZATION, + GIGET_PROVIDER, + START_SCRIPT_KEY, + START_SCRIPT_VALUE, +} from "./constants"; import { detectStarterId } from "./lib/starters"; export type SliceMachineInitProcessOptions = { repository?: string; + starter?: string; + directoryName?: string; push?: boolean; pushSlices?: boolean; pushCustomTypes?: boolean; @@ -97,27 +105,37 @@ export class SliceMachineInitProcess { )} Init command started\n`, ); - if (await this.manager.telemetry.checkIsTelemetryEnabled()) { - // We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better - // eslint-disable-next-line no-console - console.log( - `${ - logSymbols.info - } We collect telemetry data to improve user experience.\n Learn more: ${chalk.cyan( - "https://prismic.dev/slice-machine/telemetry", - )}\n`, - ); - } - await this.manager.telemetry.initTelemetry({ - appName: pkg.name, - appVersion: pkg.version, - }); - await this.manager.telemetry.track({ - event: "command:init:start", - repository: this.options.repository, - }); - try { + if (this.options.starter) { + await this.copyStarter(); + } else if (this.options.directoryName) { + // We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better + // eslint-disable-next-line no-console + console.log( + `${logSymbols.warning} --directory-name has no effect because --starter is not specified\n`, + ); + } + + if (await this.manager.telemetry.checkIsTelemetryEnabled()) { + // We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better + // eslint-disable-next-line no-console + console.log( + `${ + logSymbols.info + } We collect telemetry data to improve user experience.\n Learn more: ${chalk.cyan( + "https://prismic.dev/slice-machine/telemetry", + )}\n`, + ); + } + await this.manager.telemetry.initTelemetry({ + appName: pkg.name, + appVersion: pkg.version, + }); + await this.manager.telemetry.track({ + event: "command:init:start", + repository: this.options.repository, + }); + await this.detectEnvironment(); assertExists( @@ -291,6 +309,72 @@ GETTING STARTED }); }; + protected async copyStarter(): Promise { + const dir = await this.getStarterDirectoryName(); + + return listrRun([ + { + title: "Copying starter...\n", + task: async () => { + const starter = this.options.starter; + + await downloadTemplate( + `${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`, + { + dir, + }, + ); + + process.chdir(dir); + this.manager.cwd = process.cwd(); + }, + }, + ]); + } + + protected async getStarterDirectoryName(): Promise { + let directoryName: string; + const folderNames = await fs.readdir(process.cwd()); + + if ( + this.options.directoryName && + !folderNames.includes(this.options.directoryName) + ) { + // Use provided directory + directoryName = this.options.directoryName; + } else if ( + this.options.repository && + !folderNames.includes(this.options.repository) + ) { + // Use repository name + directoryName = this.options.repository; + } else { + // Use random name + let suggestedName: string; + do { + suggestedName = getRandomRepositoryDomain(); + } while (folderNames.includes(suggestedName)); + + const { selectedDirectory } = await prompt({ + type: "text", + name: "selectedDirectory", + message: "Your starter directory name", + initial: suggestedName, + validate: async (rawDirectory: string) => { + if (folderNames.includes(rawDirectory)) { + return "Directory name already exists"; + } + + return true; + }, + }); + + directoryName = selectedDirectory; + } + + return directoryName; + } + protected detectEnvironment(): Promise { return listrRun([ { @@ -654,26 +738,26 @@ GETTING STARTED } }; - // 1. Try to suggest name after package name - try { - const pkgJSONPath = path.join(this.manager.cwd, "package.json"); - const pkg = JSON.parse(await fs.readFile(pkgJSONPath, "utf-8")); - - const maybeSuggestion = await trySuggestName(pkg.name); - if (maybeSuggestion) { - suggestedName = maybeSuggestion; - } - } catch { - // Noop + // 1. Try to suggest name after directory name + const maybeSuggestion = await trySuggestName( + path.basename(this.manager.cwd), + ); + if (maybeSuggestion) { + suggestedName = maybeSuggestion; } - // 2. Try to suggest name after directory name + // 2. Try to suggest name after package name if (!suggestedName) { - const maybeSuggestion = await trySuggestName( - path.basename(this.manager.cwd), - ); - if (maybeSuggestion) { - suggestedName = maybeSuggestion; + try { + const pkgJSONPath = path.join(this.manager.cwd, "package.json"); + const pkg = JSON.parse(await fs.readFile(pkgJSONPath, "utf-8")); + + const maybeSuggestion = await trySuggestName(pkg.name); + if (maybeSuggestion) { + suggestedName = maybeSuggestion; + } + } catch { + // Noop } } diff --git a/packages/init/src/cli.ts b/packages/init/src/cli.ts index 1cf5de474e..91e0438f59 100644 --- a/packages/init/src/cli.ts +++ b/packages/init/src/cli.ts @@ -5,7 +5,7 @@ import { createSliceMachineInitProcess } from "./SliceMachineInitProcess"; const cli = meow( ` -Prismic Slice Machine Init CLI +Slice Machine init CLI help DOCUMENTATION https://prismic.io/docs @@ -17,13 +17,15 @@ USAGE $ npx @slicemachine/init OPTIONS - --repository, -r Specify a Prismic repository to use + --repository, -r Specify a Prismic repository to use + --starter, -s Specify a starter to use + --directory-name, -d Name of a new directory for the starter - --no-push For starters, prevent anything from being pushed - --no-push-slices For starters, prevent slices from being pushed - --no-push-custom-types For starters, prevent types from being pushed - --no-push-documents For starters, prevent documents from being pushed - --no-start-slicemachine Prevents init from running SliceMachine + --no-push Don't push anything to Prismic + --no-push-slices Don't push slices to Prismic + --no-push-custom-types Don't push types to Prismic + --no-push-documents Don't push documents to Prismic + --no-start-slicemachine Don't run Slice Machine --help, -h Display CLI help --version, -v Display CLI version @@ -35,6 +37,14 @@ OPTIONS type: "string", alias: "r", }, + starter: { + type: "string", + alias: "s", + }, + directoryName: { + type: "string", + alias: "d", + }, push: { type: "boolean", default: true, diff --git a/packages/init/src/constants.ts b/packages/init/src/constants.ts index 0ef0211e73..09c46eaf6a 100644 --- a/packages/init/src/constants.ts +++ b/packages/init/src/constants.ts @@ -1,3 +1,5 @@ // Those contants should be unique to the init script, if they are needed elsewhere then they should be extracted to the manager export const START_SCRIPT_KEY = "slicemachine"; export const START_SCRIPT_VALUE = "start-slicemachine"; +export const GIGET_PROVIDER = "github"; +export const GIGET_ORGANIZATION = "prismicio-community"; diff --git a/packages/init/test/SliceMachineInitProcess-selectRepository.test.ts b/packages/init/test/SliceMachineInitProcess-selectRepository.test.ts index 96b90eb91f..293f924662 100644 --- a/packages/init/test/SliceMachineInitProcess-selectRepository.test.ts +++ b/packages/init/test/SliceMachineInitProcess-selectRepository.test.ts @@ -295,7 +295,7 @@ it("checks for new repository name to be available", async (ctx) => { }); }); -it("suggests new repository name based on package.json first", async (ctx) => { +it("suggests new repository name based on directory name first", async (ctx) => { await mockPrismicAPIs(ctx, initProcess, []); await watchStd(async () => { @@ -320,14 +320,14 @@ it("suggests new repository name based on package.json first", async (ctx) => { // @ts-expect-error - Accessing protected property expect(initProcess.context.repository).toMatchInlineSnapshot(` { - "domain": "package-base", + "domain": "base", "exists": false, } `); }); -it("suggests new repository name based on directory name second", async (ctx) => { - await mockPrismicAPIs(ctx, initProcess, ["package-base"]); +it("suggests new repository name based on package.json second", async (ctx) => { + await mockPrismicAPIs(ctx, initProcess, ["base"]); await watchStd(async () => { const stdin = mockStdin(); @@ -351,7 +351,7 @@ it("suggests new repository name based on directory name second", async (ctx) => // @ts-expect-error - Accessing protected property expect(initProcess.context.repository).toMatchInlineSnapshot(` { - "domain": "base", + "domain": "package-base", "exists": false, } `); diff --git a/yarn.lock b/yarn.lock index 9f8451ff88..a02c6336ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7724,6 +7724,7 @@ __metadata: eslint-plugin-prettier: 4.2.1 eslint-plugin-tsdoc: 0.2.17 execa: 7.1.1 + giget: ^1.1.2 globby: ^13.1.3 hook-std: 3.0.0 listr: ^0.14.3 From bcac685310cb0d3a361e5f7589ef8e02267f2ed6 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 23 Aug 2023 15:14:32 +0200 Subject: [PATCH 2/8] feat(init): Propose to open dashboard instead of slice machine after init with starter (#1112) --- package.json | 4 +- packages/init/src/SliceMachineInitProcess.ts | 50 ++++++++++++++++--- .../test/SliceMachineInitProcess-run.test.ts | 28 +++++++---- packages/start-slicemachine/src/cli.ts | 4 +- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 9fa8742f55..3d907a6fa8 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "prettier:fix": "prettier --write .", "prettier:check": "prettier --check .", "test": "yarn workspaces foreach --parallel --topological-dev --verbose run test", - "test:e2e": "yarn cypress-setup && start-server-and-test 'npm run dev --prefix e2e-projects/cypress-next-app' http://localhost:3000 'SM_ENV=development ENABLE_SENTRY=false npm run slicemachine --prefix e2e-projects/cypress-next-app -- --no-open' http://localhost:9999 'cypress run'", - "test:e2e:dev": "yarn cypress-setup && start-server-and-test 'npm run dev --prefix e2e-projects/cypress-next-app' http://localhost:3000 'SM_ENV=staging ENABLE_SENTRY=false npm run slicemachine --prefix e2e-projects/cypress-next-app -- --no-open' http://localhost:9999 'cypress open'", + "test:e2e": "yarn cypress-setup && start-server-and-test 'npm run dev --prefix e2e-projects/cypress-next-app' http://localhost:3000 'SM_ENV=development ENABLE_SENTRY=false npm run slicemachine --prefix e2e-projects/cypress-next-app' http://localhost:9999 'cypress run'", + "test:e2e:dev": "yarn cypress-setup && start-server-and-test 'npm run dev --prefix e2e-projects/cypress-next-app' http://localhost:3000 'SM_ENV=staging ENABLE_SENTRY=false npm run slicemachine --prefix e2e-projects/cypress-next-app' http://localhost:9999 'cypress open'", "cy:open": "cypress open", "bump:interactive": "lerna version prerelease --preid alpha --no-push --exact", "bump:alpha": "lerna version prerelease --preid $npm_config_preid --no-changelog --exact --yes", diff --git a/packages/init/src/SliceMachineInitProcess.ts b/packages/init/src/SliceMachineInitProcess.ts index 25fb434cd7..8dabccf4e4 100644 --- a/packages/init/src/SliceMachineInitProcess.ts +++ b/packages/init/src/SliceMachineInitProcess.ts @@ -102,7 +102,7 @@ export class SliceMachineInitProcess { console.log( `\n${chalk.bgGray(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim( "→", - )} Init command started\n`, + )} Initializing\n`, ); try { @@ -192,7 +192,7 @@ export class SliceMachineInitProcess { console.log( `\n${chalk.bgGreen(` ${chalk.bold.white("Slice Machine")} `)} ${chalk.dim( "→", - )} Init command successful!`, + )} Initialization successful!`, ); try { @@ -211,15 +211,49 @@ export class SliceMachineInitProcess { script: "dev", }); + const apiEndpoints = this.manager.getAPIEndpoints(); + const wroomHost = new URL(apiEndpoints.PrismicWroom).host; + + const dashboardURL = new URL( + `https://${this.context.repository.domain}.${wroomHost}`, + ) + .toString() + .replace(/\/$/, ""); + const apiURL = new URL( + "./api/v2", + `https://${this.context.repository.domain}.cdn.${wroomHost}`, + ).toString(); + // We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better // eslint-disable-next-line no-console console.log(` -GETTING STARTED - Run Slice Machine ${chalk.cyan(runSmCommand)} - Run your project ${chalk.cyan(runProjectCommand)} + YOUR REPOSITORY + Dashboard ${chalk.cyan(dashboardURL)} + API ${chalk.cyan(apiURL)} + + RESOURCES + Documentation ${chalk.cyan( + this.context.framework.prismicDocumentation, + )} + Getting help ${chalk.cyan("https://community.prismic.io")} + + GETTING STARTED + Run Slice Machine ${chalk.cyan(runSmCommand)} + Run your project ${chalk.cyan(runProjectCommand)} `); - if (this.options.startSlicemachine) { + if (this.options.starter && this.options.repository) { + const { openDashboard } = await prompt({ + type: "confirm", + name: "openDashboard", + message: "Would you like to open your repository dashboard?", + initial: true, + }); + + if (openDashboard) { + open(dashboardURL); + } + } else if (this.options.startSlicemachine) { const pkgJSONPath = path.join(this.manager.cwd, "package.json"); const pkg = JSON.parse(await fs.readFile(pkgJSONPath, "utf-8")); const scripts = pkg.scripts || {}; @@ -232,13 +266,13 @@ GETTING STARTED ) { return { command: runProjectCommand, - message: `Would you like to launch your project + Slicemachine (${runProjectCommand})?`, + message: `Would you like to run your project and Slice Machine concurrently (${runProjectCommand})?`, }; } return { command: runSmCommand, - message: `Would you like to launch Slicemachine (${runSmCommand})?`, + message: `Would you like to run Slice Machine (${runSmCommand})?`, }; })(); const { startSlicemachine } = await prompt< diff --git a/packages/init/test/SliceMachineInitProcess-run.test.ts b/packages/init/test/SliceMachineInitProcess-run.test.ts index 732b241628..31a71411a0 100644 --- a/packages/init/test/SliceMachineInitProcess-run.test.ts +++ b/packages/init/test/SliceMachineInitProcess-run.test.ts @@ -193,11 +193,11 @@ it("runs without launching Slicemachine", async (ctx) => { }); // Starts - expect(stdout).toMatch(/Init command started/); + expect(stdout).toMatch(/Initializing/); // Uses repository name expect(stdout.join("")).toContain(repositoryName); // Succeed - expect(stdout).toMatch(/Init command successful/); + expect(stdout).toMatch(/Initialization successful/); }); it("runs and asks for slicemachine launch", async (ctx) => { @@ -216,11 +216,11 @@ it("runs and asks for slicemachine launch", async (ctx) => { }); // Starts - expect(stdout).toMatch(/Init command started/); + expect(stdout).toMatch(/Initializing/); // Uses repository name expect(stdout.join("")).toContain(repositoryName); // Succeed - expect(stdout).toMatch(/Init command successful/); + expect(stdout).toMatch(/Initialization successful/); }); it.skip("runs it all with new repo", async (ctx) => { @@ -236,13 +236,13 @@ it.skip("runs it all with new repo", async (ctx) => { }); // Starts - expect(stdout).toMatch(/Init command started/); + expect(stdout).toMatch(/Initializing/); // Uses repository name expect(stdout.join("")).toContain(repositoryName); // Creates repository expect(stdout).toMatch(/Created new repository/); // Succeed - expect(stdout).toMatch(/Init command successful/); + expect(stdout).toMatch(/Initialization successful/); }); it("outputs get started final message", async (ctx) => { @@ -258,12 +258,20 @@ it("outputs get started final message", async (ctx) => { return initProcess.run(); }); - expect(stdout).toMatch(/Init command successful/); + expect(stdout).toMatch(/Initialization successful/); expect(stdout.pop()).toMatchInlineSnapshot(` " - GETTING STARTED - Run Slice Machine npm run slicemachine - Run your project npm run dev + YOUR REPOSITORY + Dashboard https://repo-admin.prismic.io + API https://repo-admin.cdn.prismic.io/api/v2 + + RESOURCES + Documentation https://prismic.dev/init/universal + Getting help https://community.prismic.io + + GETTING STARTED + Run Slice Machine npm run slicemachine + Run your project npm run dev " `); diff --git a/packages/start-slicemachine/src/cli.ts b/packages/start-slicemachine/src/cli.ts index ffa800444c..8cf1fd2ddd 100644 --- a/packages/start-slicemachine/src/cli.ts +++ b/packages/start-slicemachine/src/cli.ts @@ -18,7 +18,7 @@ const args = mri(process.argv.slice(2), { version: "v", }, default: { - open: true, + open: false, help: false, version: false, }, @@ -31,7 +31,7 @@ Usage: start-slicemachine [options...] Options: - --no-open Don't open Slice Machine automatically + --open Open Slice Machine automatically --port, -p Specify the port on which to run Slice Machine --help, -h Show help text --version, -v Show version From 4cab81e23a88df2ad4c11c60bc72b8968c70bddf Mon Sep 17 00:00:00 2001 From: xrutayisire Date: Wed, 23 Aug 2023 13:30:32 +0000 Subject: [PATCH 3/8] Publish - cimsirp@1.9.1-dev-next-release.0 - @slicemachine/adapter-next@0.3.12-dev-next-release.0 - @slicemachine/adapter-nuxt@0.3.12-dev-next-release.0 - @slicemachine/adapter-nuxt2@0.3.12-dev-next-release.0 - @slicemachine/init@2.4.4-dev-next-release.0 - @slicemachine/manager@0.9.2-dev-next-release.0 - @slicemachine/plugin-kit@0.4.12-dev-next-release.0 - slice-machine-ui@1.9.1-dev-next-release.0 - start-slicemachine@0.11.2-dev-next-release.0 --- e2e-projects/next/package.json | 2 +- packages/adapter-next/package.json | 2 +- packages/adapter-nuxt/package.json | 2 +- packages/adapter-nuxt2/package.json | 2 +- packages/init/package.json | 2 +- packages/manager/package.json | 2 +- packages/plugin-kit/package.json | 2 +- packages/slice-machine/package.json | 2 +- packages/start-slicemachine/package.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/e2e-projects/next/package.json b/e2e-projects/next/package.json index d9a9362365..3d133ad29a 100644 --- a/e2e-projects/next/package.json +++ b/e2e-projects/next/package.json @@ -1,6 +1,6 @@ { "name": "cimsirp", - "version": "1.9.0", + "version": "1.9.1-dev-next-release.0", "private": true, "scripts": { "dev": "next dev", diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 378e3cddb5..38b24ea157 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-next", - "version": "0.3.11", + "version": "0.3.12-dev-next-release.0", "description": "Slice Machine adapter for Next.js.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index 96a0c8b186..f18b55a1ed 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt", - "version": "0.3.11", + "version": "0.3.12-dev-next-release.0", "description": "Slice Machine adapter for Nuxt 3.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt2/package.json b/packages/adapter-nuxt2/package.json index 60cee65dad..59e7cec45f 100644 --- a/packages/adapter-nuxt2/package.json +++ b/packages/adapter-nuxt2/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt2", - "version": "0.3.11", + "version": "0.3.12-dev-next-release.0", "description": "Slice Machine adapter for Nuxt 2.", "keywords": [ "typescript", diff --git a/packages/init/package.json b/packages/init/package.json index e00dc74efa..0c3cfae191 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/init", - "version": "2.4.3", + "version": "2.4.4-dev-next-release.0", "description": "Init Prismic Slice Machine in your project", "keywords": [ "typescript", diff --git a/packages/manager/package.json b/packages/manager/package.json index 0c6e6bd938..35aac8e4bb 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/manager", - "version": "0.9.1", + "version": "0.9.2-dev-next-release.0", "description": "Manage all aspects of a Slice Machine project.", "repository": { "type": "git", diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index 968b037f66..a64ec774a8 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/plugin-kit", - "version": "0.4.11", + "version": "0.4.12-dev-next-release.0", "description": "A set of helpers to develop and run Slice Machine plugins", "keywords": [ "typescript", diff --git a/packages/slice-machine/package.json b/packages/slice-machine/package.json index bd0a40a9c0..23930ef208 100644 --- a/packages/slice-machine/package.json +++ b/packages/slice-machine/package.json @@ -1,6 +1,6 @@ { "name": "slice-machine-ui", - "version": "1.9.0", + "version": "1.9.1-dev-next-release.0", "license": "MIT", "description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.", "repository": { diff --git a/packages/start-slicemachine/package.json b/packages/start-slicemachine/package.json index da9d6b562c..96ca6296a5 100644 --- a/packages/start-slicemachine/package.json +++ b/packages/start-slicemachine/package.json @@ -1,6 +1,6 @@ { "name": "start-slicemachine", - "version": "0.11.1", + "version": "0.11.2-dev-next-release.0", "description": "Start Slice Machine from within a project.", "repository": { "type": "git", From 3b1ecbcd52b0f26bb5529e3fbd30c0df0ab8bd6c Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 23 Aug 2023 15:45:13 +0200 Subject: [PATCH 4/8] fix(init): Move down call to get starter directory name --- packages/init/src/SliceMachineInitProcess.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/init/src/SliceMachineInitProcess.ts b/packages/init/src/SliceMachineInitProcess.ts index 8dabccf4e4..6099dcff39 100644 --- a/packages/init/src/SliceMachineInitProcess.ts +++ b/packages/init/src/SliceMachineInitProcess.ts @@ -344,13 +344,12 @@ export class SliceMachineInitProcess { }; protected async copyStarter(): Promise { - const dir = await this.getStarterDirectoryName(); - return listrRun([ { title: "Copying starter...\n", task: async () => { const starter = this.options.starter; + const dir = await this.getStarterDirectoryName(); await downloadTemplate( `${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`, From 2f048d9021e6332a3c82d297cc047820e7f6754a Mon Sep 17 00:00:00 2001 From: xrutayisire Date: Wed, 23 Aug 2023 14:02:39 +0000 Subject: [PATCH 5/8] Publish - cimsirp@1.9.1-dev-next-release.1 - @slicemachine/adapter-next@0.3.12-dev-next-release.1 - @slicemachine/adapter-nuxt@0.3.12-dev-next-release.1 - @slicemachine/adapter-nuxt2@0.3.12-dev-next-release.1 - @slicemachine/init@2.4.4-dev-next-release.1 - @slicemachine/manager@0.9.2-dev-next-release.1 - @slicemachine/plugin-kit@0.4.12-dev-next-release.1 - slice-machine-ui@1.9.1-dev-next-release.1 - start-slicemachine@0.11.2-dev-next-release.1 --- e2e-projects/next/package.json | 2 +- packages/adapter-next/package.json | 2 +- packages/adapter-nuxt/package.json | 2 +- packages/adapter-nuxt2/package.json | 2 +- packages/init/package.json | 2 +- packages/manager/package.json | 2 +- packages/plugin-kit/package.json | 2 +- packages/slice-machine/package.json | 2 +- packages/start-slicemachine/package.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/e2e-projects/next/package.json b/e2e-projects/next/package.json index 3d133ad29a..0d4a6c91e2 100644 --- a/e2e-projects/next/package.json +++ b/e2e-projects/next/package.json @@ -1,6 +1,6 @@ { "name": "cimsirp", - "version": "1.9.1-dev-next-release.0", + "version": "1.9.1-dev-next-release.1", "private": true, "scripts": { "dev": "next dev", diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 38b24ea157..d3ff12c8e6 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-next", - "version": "0.3.12-dev-next-release.0", + "version": "0.3.12-dev-next-release.1", "description": "Slice Machine adapter for Next.js.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index f18b55a1ed..b46491faa1 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt", - "version": "0.3.12-dev-next-release.0", + "version": "0.3.12-dev-next-release.1", "description": "Slice Machine adapter for Nuxt 3.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt2/package.json b/packages/adapter-nuxt2/package.json index 59e7cec45f..4dfcf29ddd 100644 --- a/packages/adapter-nuxt2/package.json +++ b/packages/adapter-nuxt2/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt2", - "version": "0.3.12-dev-next-release.0", + "version": "0.3.12-dev-next-release.1", "description": "Slice Machine adapter for Nuxt 2.", "keywords": [ "typescript", diff --git a/packages/init/package.json b/packages/init/package.json index 0c3cfae191..39f27490ac 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/init", - "version": "2.4.4-dev-next-release.0", + "version": "2.4.4-dev-next-release.1", "description": "Init Prismic Slice Machine in your project", "keywords": [ "typescript", diff --git a/packages/manager/package.json b/packages/manager/package.json index 35aac8e4bb..68c237273f 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/manager", - "version": "0.9.2-dev-next-release.0", + "version": "0.9.2-dev-next-release.1", "description": "Manage all aspects of a Slice Machine project.", "repository": { "type": "git", diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index a64ec774a8..c5c2bd60a2 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/plugin-kit", - "version": "0.4.12-dev-next-release.0", + "version": "0.4.12-dev-next-release.1", "description": "A set of helpers to develop and run Slice Machine plugins", "keywords": [ "typescript", diff --git a/packages/slice-machine/package.json b/packages/slice-machine/package.json index 23930ef208..7c7407fa24 100644 --- a/packages/slice-machine/package.json +++ b/packages/slice-machine/package.json @@ -1,6 +1,6 @@ { "name": "slice-machine-ui", - "version": "1.9.1-dev-next-release.0", + "version": "1.9.1-dev-next-release.1", "license": "MIT", "description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.", "repository": { diff --git a/packages/start-slicemachine/package.json b/packages/start-slicemachine/package.json index 96ca6296a5..628cf51f4d 100644 --- a/packages/start-slicemachine/package.json +++ b/packages/start-slicemachine/package.json @@ -1,6 +1,6 @@ { "name": "start-slicemachine", - "version": "0.11.2-dev-next-release.0", + "version": "0.11.2-dev-next-release.1", "description": "Start Slice Machine from within a project.", "repository": { "type": "git", From 3f0e5537faf2fbb9082eb0b722859b553ae47042 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 23 Aug 2023 16:31:31 +0200 Subject: [PATCH 6/8] wording(init): reword init message for starter copy --- packages/init/src/SliceMachineInitProcess.ts | 11 +++++++---- .../init/test/SliceMachineInitProcess-run.test.ts | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/init/src/SliceMachineInitProcess.ts b/packages/init/src/SliceMachineInitProcess.ts index 6099dcff39..19fcf29e54 100644 --- a/packages/init/src/SliceMachineInitProcess.ts +++ b/packages/init/src/SliceMachineInitProcess.ts @@ -228,7 +228,7 @@ export class SliceMachineInitProcess { // eslint-disable-next-line no-console console.log(` YOUR REPOSITORY - Dashboard ${chalk.cyan(dashboardURL)} + Page Builder ${chalk.cyan(dashboardURL)} API ${chalk.cyan(apiURL)} RESOURCES @@ -246,7 +246,7 @@ export class SliceMachineInitProcess { const { openDashboard } = await prompt({ type: "confirm", name: "openDashboard", - message: "Would you like to open your repository dashboard?", + message: "Would you like to open your repository?", initial: true, }); @@ -344,12 +344,13 @@ export class SliceMachineInitProcess { }; protected async copyStarter(): Promise { + const dir = await this.getStarterDirectoryName(); + return listrRun([ { title: "Copying starter...\n", - task: async () => { + task: async (_, task) => { const starter = this.options.starter; - const dir = await this.getStarterDirectoryName(); await downloadTemplate( `${GIGET_PROVIDER}:${GIGET_ORGANIZATION}/${starter}#HEAD`, @@ -360,6 +361,8 @@ export class SliceMachineInitProcess { process.chdir(dir); this.manager.cwd = process.cwd(); + + task.title = "Starter copied\n"; }, }, ]); diff --git a/packages/init/test/SliceMachineInitProcess-run.test.ts b/packages/init/test/SliceMachineInitProcess-run.test.ts index 31a71411a0..fcfcecea85 100644 --- a/packages/init/test/SliceMachineInitProcess-run.test.ts +++ b/packages/init/test/SliceMachineInitProcess-run.test.ts @@ -262,7 +262,7 @@ it("outputs get started final message", async (ctx) => { expect(stdout.pop()).toMatchInlineSnapshot(` " YOUR REPOSITORY - Dashboard https://repo-admin.prismic.io + Page Builder https://repo-admin.prismic.io API https://repo-admin.cdn.prismic.io/api/v2 RESOURCES From 21c220e69615876ac421f9971171981d13897373 Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Wed, 23 Aug 2023 17:38:27 +0200 Subject: [PATCH 7/8] fix(ini): Fix login stuck for starter --- packages/init/src/SliceMachineInitProcess.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/init/src/SliceMachineInitProcess.ts b/packages/init/src/SliceMachineInitProcess.ts index 19fcf29e54..d852c6105a 100644 --- a/packages/init/src/SliceMachineInitProcess.ts +++ b/packages/init/src/SliceMachineInitProcess.ts @@ -593,6 +593,7 @@ export class SliceMachineInitProcess { await new Promise((resolve) => { const initialRawMode = !!process.stdin.isRaw; process.stdin.setRawMode?.(true); + process.stdin.resume(); process.stdin.once("data", (data: Buffer) => { process.stdin.setRawMode?.(initialRawMode); process.stdin.pause(); From d82366053efb07f30159f6899bfee3a7ec15955f Mon Sep 17 00:00:00 2001 From: xrutayisire Date: Wed, 23 Aug 2023 15:55:44 +0000 Subject: [PATCH 8/8] Publish - cimsirp@1.9.1-dev-next-release.2 - @slicemachine/adapter-next@0.3.12-dev-next-release.2 - @slicemachine/adapter-nuxt@0.3.12-dev-next-release.2 - @slicemachine/adapter-nuxt2@0.3.12-dev-next-release.2 - @slicemachine/init@2.4.4-dev-next-release.2 - @slicemachine/manager@0.9.2-dev-next-release.2 - @slicemachine/plugin-kit@0.4.12-dev-next-release.2 - slice-machine-ui@1.9.1-dev-next-release.2 - start-slicemachine@0.11.2-dev-next-release.2 --- e2e-projects/next/package.json | 2 +- packages/adapter-next/package.json | 2 +- packages/adapter-nuxt/package.json | 2 +- packages/adapter-nuxt2/package.json | 2 +- packages/init/package.json | 2 +- packages/manager/package.json | 2 +- packages/plugin-kit/package.json | 2 +- packages/slice-machine/package.json | 2 +- packages/start-slicemachine/package.json | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/e2e-projects/next/package.json b/e2e-projects/next/package.json index 0d4a6c91e2..7d239b3b53 100644 --- a/e2e-projects/next/package.json +++ b/e2e-projects/next/package.json @@ -1,6 +1,6 @@ { "name": "cimsirp", - "version": "1.9.1-dev-next-release.1", + "version": "1.9.1-dev-next-release.2", "private": true, "scripts": { "dev": "next dev", diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index d3ff12c8e6..cc608590c6 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-next", - "version": "0.3.12-dev-next-release.1", + "version": "0.3.12-dev-next-release.2", "description": "Slice Machine adapter for Next.js.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt/package.json b/packages/adapter-nuxt/package.json index b46491faa1..5f55e396f5 100644 --- a/packages/adapter-nuxt/package.json +++ b/packages/adapter-nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt", - "version": "0.3.12-dev-next-release.1", + "version": "0.3.12-dev-next-release.2", "description": "Slice Machine adapter for Nuxt 3.", "keywords": [ "typescript", diff --git a/packages/adapter-nuxt2/package.json b/packages/adapter-nuxt2/package.json index 4dfcf29ddd..211aaa5ade 100644 --- a/packages/adapter-nuxt2/package.json +++ b/packages/adapter-nuxt2/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/adapter-nuxt2", - "version": "0.3.12-dev-next-release.1", + "version": "0.3.12-dev-next-release.2", "description": "Slice Machine adapter for Nuxt 2.", "keywords": [ "typescript", diff --git a/packages/init/package.json b/packages/init/package.json index 39f27490ac..ae4a5ab143 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/init", - "version": "2.4.4-dev-next-release.1", + "version": "2.4.4-dev-next-release.2", "description": "Init Prismic Slice Machine in your project", "keywords": [ "typescript", diff --git a/packages/manager/package.json b/packages/manager/package.json index 68c237273f..d10f57203d 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/manager", - "version": "0.9.2-dev-next-release.1", + "version": "0.9.2-dev-next-release.2", "description": "Manage all aspects of a Slice Machine project.", "repository": { "type": "git", diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json index c5c2bd60a2..9fb46752a4 100644 --- a/packages/plugin-kit/package.json +++ b/packages/plugin-kit/package.json @@ -1,6 +1,6 @@ { "name": "@slicemachine/plugin-kit", - "version": "0.4.12-dev-next-release.1", + "version": "0.4.12-dev-next-release.2", "description": "A set of helpers to develop and run Slice Machine plugins", "keywords": [ "typescript", diff --git a/packages/slice-machine/package.json b/packages/slice-machine/package.json index 7c7407fa24..23a824956b 100644 --- a/packages/slice-machine/package.json +++ b/packages/slice-machine/package.json @@ -1,6 +1,6 @@ { "name": "slice-machine-ui", - "version": "1.9.1-dev-next-release.1", + "version": "1.9.1-dev-next-release.2", "license": "MIT", "description": "A visual builder for your Slice Models with all the tools you need to generate data models and mock CMS content locally.", "repository": { diff --git a/packages/start-slicemachine/package.json b/packages/start-slicemachine/package.json index 628cf51f4d..44c4d02a6b 100644 --- a/packages/start-slicemachine/package.json +++ b/packages/start-slicemachine/package.json @@ -1,6 +1,6 @@ { "name": "start-slicemachine", - "version": "0.11.2-dev-next-release.1", + "version": "0.11.2-dev-next-release.2", "description": "Start Slice Machine from within a project.", "repository": { "type": "git",