@slicemachine/init 2.1.1-dev-page-types-m2.0 → 2.1.1-dev-hotfixes.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.
- package/dist/SliceMachineInitProcess.cjs +16 -3
- package/dist/SliceMachineInitProcess.cjs.map +1 -1
- package/dist/SliceMachineInitProcess.d.ts +2 -1
- package/dist/SliceMachineInitProcess.js +16 -3
- package/dist/SliceMachineInitProcess.js.map +1 -1
- package/dist/_node_modules/@babel/code-frame/lib/index.cjs +2 -2
- package/dist/_node_modules/@babel/code-frame/lib/index.js +2 -2
- package/dist/_node_modules/@babel/helper-validator-identifier/lib/index.cjs +1 -1
- package/dist/_node_modules/@babel/helper-validator-identifier/lib/index.js +1 -1
- package/dist/_node_modules/@babel/highlight/lib/index.cjs +3 -3
- package/dist/_node_modules/@babel/highlight/lib/index.js +3 -3
- package/dist/_node_modules/@nodelib/fs.scandir/out/index.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/index.js +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/async.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/async.js +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/sync.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/sync.js +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/settings.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/settings.js +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/index.cjs +4 -4
- package/dist/_node_modules/@nodelib/fs.stat/out/index.js +4 -4
- package/dist/_node_modules/@nodelib/fs.stat/out/providers/async.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/providers/async.js +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/providers/sync.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/providers/sync.js +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/settings.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/settings.js +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/index.cjs +4 -4
- package/dist/_node_modules/@nodelib/fs.walk/out/index.js +4 -4
- package/dist/_node_modules/@nodelib/fs.walk/out/providers/async.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/providers/async.js +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/providers/sync.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/providers/sync.js +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/readers/async.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/readers/async.js +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/readers/sync.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/readers/sync.js +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/settings.cjs +2 -2
- package/dist/_node_modules/@nodelib/fs.walk/out/settings.js +2 -2
- package/dist/_node_modules/camelcase-keys/index.cjs +1 -1
- package/dist/_node_modules/camelcase-keys/index.js +1 -1
- package/dist/_node_modules/dir-glob/index.cjs +1 -1
- package/dist/_node_modules/dir-glob/index.js +1 -1
- package/dist/_node_modules/fast-glob/out/index.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/index.js +1 -1
- package/dist/_node_modules/fast-glob/out/managers/tasks.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/managers/tasks.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/deep.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/deep.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/entry.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/entry.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/error.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/error.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/matchers/matcher.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/matchers/matcher.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/transformers/entry.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/transformers/entry.js +1 -1
- package/dist/_node_modules/fast-glob/out/readers/async.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/readers/async.js +1 -1
- package/dist/_node_modules/fast-glob/out/readers/reader.cjs +2 -2
- package/dist/_node_modules/fast-glob/out/readers/reader.js +2 -2
- package/dist/_node_modules/fast-glob/out/readers/stream.cjs +2 -2
- package/dist/_node_modules/fast-glob/out/readers/stream.js +2 -2
- package/dist/_node_modules/fast-glob/out/readers/sync.cjs +2 -2
- package/dist/_node_modules/fast-glob/out/readers/sync.js +2 -2
- package/dist/_node_modules/fast-glob/out/utils/index.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/utils/index.js +1 -1
- package/dist/_node_modules/js-tokens/index.cjs +1 -1
- package/dist/_node_modules/js-tokens/index.js +1 -1
- package/dist/_node_modules/lines-and-columns/build/index.cjs +1 -1
- package/dist/_node_modules/lines-and-columns/build/index.js +1 -1
- package/dist/_node_modules/map-obj/index.cjs +1 -1
- package/dist/_node_modules/map-obj/index.js +1 -1
- package/dist/_node_modules/meow/_node_modules/read-pkg/_node_modules/hosted-git-info/index.cjs +1 -1
- package/dist/_node_modules/meow/_node_modules/read-pkg/_node_modules/hosted-git-info/index.js +1 -1
- package/dist/_node_modules/meow/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/fixer.cjs +1 -1
- package/dist/_node_modules/meow/_node_modules/read-pkg/_node_modules/normalize-package-data/lib/fixer.js +1 -1
- package/dist/_node_modules/micromatch/index.cjs +1 -1
- package/dist/_node_modules/micromatch/index.js +1 -1
- package/dist/_node_modules/parse-json/index.cjs +2 -2
- package/dist/_node_modules/parse-json/index.js +2 -2
- package/dist/_node_modules/path-type/index.cjs +1 -1
- package/dist/_node_modules/path-type/index.js +1 -1
- package/dist/_node_modules/picomatch/index.cjs +1 -1
- package/dist/_node_modules/picomatch/index.js +1 -1
- package/dist/_virtual/index10.cjs +2 -2
- package/dist/_virtual/index10.js +2 -2
- package/dist/_virtual/index11.cjs +2 -2
- package/dist/_virtual/index11.js +2 -2
- package/dist/_virtual/index12.cjs +2 -2
- package/dist/_virtual/index12.js +6 -6
- package/dist/_virtual/index13.cjs +2 -10
- package/dist/_virtual/index13.cjs.map +1 -1
- package/dist/_virtual/index13.js +2 -11
- package/dist/_virtual/index13.js.map +1 -1
- package/dist/_virtual/index14.cjs +10 -2
- package/dist/_virtual/index14.cjs.map +1 -1
- package/dist/_virtual/index14.js +11 -2
- package/dist/_virtual/index14.js.map +1 -1
- package/dist/_virtual/index15.cjs +2 -2
- package/dist/_virtual/index15.js +2 -2
- package/dist/_virtual/index16.cjs +2 -2
- package/dist/_virtual/index16.js +2 -2
- package/dist/_virtual/index17.cjs +2 -2
- package/dist/_virtual/index17.js +2 -2
- package/dist/_virtual/index4.cjs +10 -2
- package/dist/_virtual/index4.cjs.map +1 -1
- package/dist/_virtual/index4.js +11 -2
- package/dist/_virtual/index4.js.map +1 -1
- package/dist/_virtual/index5.cjs +2 -2
- package/dist/_virtual/index5.js +2 -2
- package/dist/_virtual/index6.cjs +2 -10
- package/dist/_virtual/index6.cjs.map +1 -1
- package/dist/_virtual/index6.js +2 -11
- package/dist/_virtual/index6.js.map +1 -1
- package/dist/_virtual/index8.cjs +2 -2
- package/dist/_virtual/index8.js +2 -2
- package/dist/_virtual/index9.cjs +2 -2
- package/dist/_virtual/index9.js +2 -2
- package/dist/lib/framework.cjs +8 -4
- package/dist/lib/framework.cjs.map +1 -1
- package/dist/lib/framework.d.ts +7 -2
- package/dist/lib/framework.js +8 -4
- package/dist/lib/framework.js.map +1 -1
- package/dist/lib/starters.cjs +23 -0
- package/dist/lib/starters.cjs.map +1 -0
- package/dist/lib/starters.d.ts +2 -0
- package/dist/lib/starters.js +23 -0
- package/dist/lib/starters.js.map +1 -0
- package/dist/packages/init/package.json.cjs +4 -4
- package/dist/packages/init/package.json.js +4 -4
- package/package.json +4 -4
- package/src/SliceMachineInitProcess.ts +23 -3
- package/src/lib/framework.ts +17 -7
- package/src/lib/starters.ts +30 -0
|
@@ -13,10 +13,12 @@ import {
|
|
|
13
13
|
PrismicRepository,
|
|
14
14
|
SliceMachineManager,
|
|
15
15
|
PackageManager,
|
|
16
|
+
StarterID,
|
|
16
17
|
} from "@slicemachine/manager";
|
|
17
18
|
|
|
18
19
|
import pkg from "../package.json";
|
|
19
20
|
import { detectFramework, Framework } from "./lib/framework";
|
|
21
|
+
import { detectStarterId } from "./lib/starters";
|
|
20
22
|
import { getRunScriptCommand } from "./lib/getRunScriptCommand";
|
|
21
23
|
import { getExecuteCommand } from "./lib/getExecuteCommand";
|
|
22
24
|
import {
|
|
@@ -66,6 +68,7 @@ type SliceMachineInitProcessContext = {
|
|
|
66
68
|
projectInitialization?: {
|
|
67
69
|
patchedScript?: boolean;
|
|
68
70
|
};
|
|
71
|
+
starterID?: StarterID;
|
|
69
72
|
};
|
|
70
73
|
|
|
71
74
|
export class SliceMachineInitProcess {
|
|
@@ -149,7 +152,7 @@ export class SliceMachineInitProcess {
|
|
|
149
152
|
|
|
150
153
|
await this.manager.telemetry.track({
|
|
151
154
|
event: "command:init:end",
|
|
152
|
-
framework: this.context.framework.
|
|
155
|
+
framework: this.context.framework.sliceMachineTelemetryID,
|
|
153
156
|
repository: this.context.repository.domain,
|
|
154
157
|
success: true,
|
|
155
158
|
});
|
|
@@ -220,7 +223,7 @@ export class SliceMachineInitProcess {
|
|
|
220
223
|
|
|
221
224
|
return this.manager.telemetry.track({
|
|
222
225
|
event: "command:init:end",
|
|
223
|
-
framework: this.context.framework?.
|
|
226
|
+
framework: this.context.framework?.sliceMachineTelemetryID ?? "unknown",
|
|
224
227
|
repository: this.context.repository?.domain,
|
|
225
228
|
success: false,
|
|
226
229
|
error: safeError,
|
|
@@ -268,6 +271,22 @@ export class SliceMachineInitProcess {
|
|
|
268
271
|
)}`;
|
|
269
272
|
},
|
|
270
273
|
},
|
|
274
|
+
{
|
|
275
|
+
title: "Detecting starter...",
|
|
276
|
+
task: async (_, task) => {
|
|
277
|
+
this.context.starterID = await detectStarterId(
|
|
278
|
+
this.manager.cwd,
|
|
279
|
+
);
|
|
280
|
+
|
|
281
|
+
if (this.context.starterID) {
|
|
282
|
+
task.title = `Detected starter ${chalk.cyan(
|
|
283
|
+
this.context.starterID,
|
|
284
|
+
)}`;
|
|
285
|
+
} else {
|
|
286
|
+
task.title = "No starter detected";
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
},
|
|
271
290
|
]),
|
|
272
291
|
},
|
|
273
292
|
]);
|
|
@@ -683,7 +702,8 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
683
702
|
|
|
684
703
|
await this.manager.prismicRepository.create({
|
|
685
704
|
domain: this.context.repository.domain,
|
|
686
|
-
framework: this.context.framework.
|
|
705
|
+
framework: this.context.framework.wroomTelemetryID,
|
|
706
|
+
starterID: this.context.starterID,
|
|
687
707
|
});
|
|
688
708
|
|
|
689
709
|
this.context.repository.exists = true;
|
package/src/lib/framework.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
|
|
4
3
|
import semver from "semver";
|
|
5
4
|
|
|
5
|
+
import { FrameworkWroomTelemetryID } from "@slicemachine/manager";
|
|
6
|
+
|
|
6
7
|
import { version as pkgVersion } from "../../package.json";
|
|
7
8
|
|
|
8
9
|
export type Framework = {
|
|
@@ -12,9 +13,14 @@ export type Framework = {
|
|
|
12
13
|
name: string;
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
* Framework's
|
|
16
|
+
* Framework 's id sent to Segment from Slice Machine
|
|
17
|
+
*/
|
|
18
|
+
sliceMachineTelemetryID: "next-11-13" | "nuxt-2" | "nuxt-3" | "universal";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Framework's id sent to Segment from wroom.
|
|
16
22
|
*/
|
|
17
|
-
|
|
23
|
+
wroomTelemetryID: FrameworkWroomTelemetryID;
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* A link to the Prismic documentation for the framework
|
|
@@ -60,7 +66,8 @@ const DEFAULT_DEV_DEPENDENCIES: Record<string, string> = {
|
|
|
60
66
|
export const FRAMEWORKS: Record<string, Framework> = {
|
|
61
67
|
"nuxt-2": {
|
|
62
68
|
name: "Nuxt 2",
|
|
63
|
-
|
|
69
|
+
sliceMachineTelemetryID: "nuxt-2",
|
|
70
|
+
wroomTelemetryID: "nuxt",
|
|
64
71
|
prismicDocumentation: "https://prismic.dev/init/nuxt-2",
|
|
65
72
|
adapterName: "@slicemachine/adapter-nuxt2",
|
|
66
73
|
compatibility: {
|
|
@@ -73,7 +80,8 @@ export const FRAMEWORKS: Record<string, Framework> = {
|
|
|
73
80
|
},
|
|
74
81
|
"nuxt-3": {
|
|
75
82
|
name: "Nuxt 3",
|
|
76
|
-
|
|
83
|
+
sliceMachineTelemetryID: "nuxt-3",
|
|
84
|
+
wroomTelemetryID: "nuxt",
|
|
77
85
|
prismicDocumentation: "https://prismic.dev/init/nuxt-3",
|
|
78
86
|
adapterName: "@slicemachine/adapter-nuxt",
|
|
79
87
|
compatibility: {
|
|
@@ -86,7 +94,8 @@ export const FRAMEWORKS: Record<string, Framework> = {
|
|
|
86
94
|
},
|
|
87
95
|
"next-11-13": {
|
|
88
96
|
name: "Next.js 11-13",
|
|
89
|
-
|
|
97
|
+
sliceMachineTelemetryID: "next-11-13",
|
|
98
|
+
wroomTelemetryID: "next",
|
|
90
99
|
prismicDocumentation: "https://prismic.dev/init/next-11-13",
|
|
91
100
|
adapterName: "@slicemachine/adapter-next",
|
|
92
101
|
compatibility: {
|
|
@@ -104,7 +113,8 @@ export const FRAMEWORKS: Record<string, Framework> = {
|
|
|
104
113
|
*/
|
|
105
114
|
export const UNIVERSAL: Framework = {
|
|
106
115
|
name: "universal (no framework)",
|
|
107
|
-
|
|
116
|
+
sliceMachineTelemetryID: "universal",
|
|
117
|
+
wroomTelemetryID: "other",
|
|
108
118
|
prismicDocumentation: "https://prismic.dev/init/universal",
|
|
109
119
|
adapterName: "@slicemachine/adapter-universal",
|
|
110
120
|
compatibility: {},
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { StarterID } from "@slicemachine/manager";
|
|
5
|
+
|
|
6
|
+
const STARTERS_REPOSITORY_NAME_TO_ID: Record<string, StarterID> = {
|
|
7
|
+
"nextjs-starter-prismic-multi-page": "next_multi_page",
|
|
8
|
+
"nextjs-starter-prismic-blog": "next_blog",
|
|
9
|
+
"nextjs-starter-prismic-multi-language": "next_multi_lang",
|
|
10
|
+
"nuxt-starter-prismic-multi-page": "nuxt_multi_page",
|
|
11
|
+
"nuxt-starter-prismic-blog": "nuxt_blog",
|
|
12
|
+
"nuxt-starter-prismic-multi-language": "nuxt_multi_lang",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const detectStarterId = async (
|
|
16
|
+
cwd: string,
|
|
17
|
+
): Promise<StarterID | undefined> => {
|
|
18
|
+
const path = join(cwd, "package.json");
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(await readFile(path, "utf-8"));
|
|
22
|
+
|
|
23
|
+
return STARTERS_REPOSITORY_NAME_TO_ID[pkg.name];
|
|
24
|
+
} catch (error) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Failed to read project's \`package.json\` at \`${path}\``,
|
|
27
|
+
{ cause: error },
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
};
|