@slicemachine/init 2.6.4-dev-upgrade-legacy.2 → 2.7.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 +29 -30
- package/dist/SliceMachineInitProcess.cjs.map +1 -1
- package/dist/SliceMachineInitProcess.d.ts +3 -1
- package/dist/SliceMachineInitProcess.js +29 -30
- 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/providers/async.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/async.js +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/sync.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/providers/sync.js +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/settings.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.scandir/out/settings.js +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/index.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.stat/out/index.js +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/index.cjs +1 -1
- package/dist/_node_modules/@nodelib/fs.walk/out/index.js +1 -1
- package/dist/_node_modules/cross-spawn/index.cjs +1 -1
- package/dist/_node_modules/cross-spawn/index.js +1 -1
- package/dist/_node_modules/dir-glob/index.cjs +2 -2
- package/dist/_node_modules/dir-glob/index.js +2 -2
- package/dist/_node_modules/fast-glob/out/index.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/index.js +1 -1
- package/dist/_node_modules/fast-glob/out/managers/tasks.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/managers/tasks.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/deep.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/deep.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/entry.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/entry.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/error.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/filters/error.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/matchers/matcher.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/matchers/matcher.js +1 -1
- package/dist/_node_modules/fast-glob/out/providers/transformers/entry.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/providers/transformers/entry.js +1 -1
- package/dist/_node_modules/fast-glob/out/readers/async.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/readers/async.js +1 -1
- package/dist/_node_modules/fast-glob/out/readers/reader.cjs +2 -2
- package/dist/_node_modules/fast-glob/out/readers/reader.js +2 -2
- package/dist/_node_modules/fast-glob/out/readers/stream.cjs +2 -2
- package/dist/_node_modules/fast-glob/out/readers/stream.js +2 -2
- package/dist/_node_modules/fast-glob/out/readers/sync.cjs +2 -2
- package/dist/_node_modules/fast-glob/out/readers/sync.js +2 -2
- package/dist/_node_modules/fast-glob/out/utils/index.cjs +1 -1
- package/dist/_node_modules/fast-glob/out/utils/index.js +1 -1
- package/dist/_node_modules/get-stream/index.cjs +1 -1
- package/dist/_node_modules/get-stream/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/hosted-git-info/lib/index.cjs +1 -1
- package/dist/_node_modules/meow/_node_modules/hosted-git-info/lib/index.js +1 -1
- package/dist/_node_modules/meow/_node_modules/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/parse-json/index.cjs +2 -2
- package/dist/_node_modules/parse-json/index.js +2 -2
- package/dist/_node_modules/path-key/index.cjs +1 -1
- package/dist/_node_modules/path-key/index.js +1 -1
- package/dist/_node_modules/path-type/index.cjs +1 -1
- package/dist/_node_modules/path-type/index.js +1 -1
- package/dist/_node_modules/signal-exit/index.cjs +1 -1
- package/dist/_node_modules/signal-exit/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 +2 -2
- package/dist/_virtual/index13.cjs +2 -2
- package/dist/_virtual/index13.js +2 -2
- package/dist/_virtual/index14.cjs +2 -2
- package/dist/_virtual/index14.js +2 -2
- 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/index18.cjs +2 -2
- package/dist/_virtual/index18.js +2 -2
- package/dist/_virtual/index19.cjs +2 -2
- package/dist/_virtual/index19.js +2 -2
- package/dist/_virtual/index3.cjs +2 -2
- package/dist/_virtual/index3.js +2 -2
- package/dist/_virtual/index4.cjs +2 -2
- package/dist/_virtual/index4.js +2 -2
- package/dist/_virtual/index5.cjs +2 -2
- package/dist/_virtual/index5.js +2 -2
- package/dist/_virtual/index6.cjs +2 -2
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.cjs +2 -2
- package/dist/_virtual/index7.js +2 -2
- 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/constants.cjs +2 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/lib/checkIsSentryEnabled.cjs +5 -0
- package/dist/lib/checkIsSentryEnabled.cjs.map +1 -0
- package/dist/lib/checkIsSentryEnabled.d.ts +9 -0
- package/dist/lib/checkIsSentryEnabled.js +5 -0
- package/dist/lib/checkIsSentryEnabled.js.map +1 -0
- package/dist/lib/sentryErrorHandlers.cjs +31 -0
- package/dist/lib/sentryErrorHandlers.cjs.map +1 -0
- package/dist/lib/sentryErrorHandlers.d.ts +1 -0
- package/dist/lib/sentryErrorHandlers.js +14 -0
- package/dist/lib/sentryErrorHandlers.js.map +1 -0
- package/dist/lib/setupSentry.cjs +37 -0
- package/dist/lib/setupSentry.cjs.map +1 -0
- package/dist/lib/setupSentry.d.ts +1 -0
- package/dist/lib/setupSentry.js +20 -0
- package/dist/lib/setupSentry.js.map +1 -0
- package/dist/lib/updateSentryContext.cjs +45 -0
- package/dist/lib/updateSentryContext.cjs.map +1 -0
- package/dist/lib/updateSentryContext.d.ts +8 -0
- package/dist/lib/updateSentryContext.js +28 -0
- package/dist/lib/updateSentryContext.js.map +1 -0
- package/dist/packages/init/package.json.cjs +6 -5
- package/dist/packages/init/package.json.cjs.map +1 -1
- package/dist/packages/init/package.json.js +6 -5
- package/dist/packages/init/package.json.js.map +1 -1
- package/package.json +6 -5
- package/src/SliceMachineInitProcess.ts +31 -51
- package/src/constants.ts +3 -0
- package/src/lib/checkIsSentryEnabled.ts +12 -0
- package/src/lib/sentryErrorHandlers.ts +13 -0
- package/src/lib/setupSentry.ts +23 -0
- package/src/lib/updateSentryContext.ts +42 -0
|
@@ -41,6 +41,9 @@ import {
|
|
|
41
41
|
START_SCRIPT_VALUE,
|
|
42
42
|
} from "./constants";
|
|
43
43
|
import { detectStarterId } from "./lib/starters";
|
|
44
|
+
import { setupSentry } from "./lib/setupSentry";
|
|
45
|
+
import { trackSentryError } from "./lib/sentryErrorHandlers";
|
|
46
|
+
import { updateSentryContext } from "./lib/updateSentryContext";
|
|
44
47
|
|
|
45
48
|
export type SliceMachineInitProcessOptions = {
|
|
46
49
|
repository?: string;
|
|
@@ -132,6 +135,7 @@ export class SliceMachineInitProcess {
|
|
|
132
135
|
appName: pkg.name,
|
|
133
136
|
appVersion: pkg.version,
|
|
134
137
|
});
|
|
138
|
+
await setupSentry();
|
|
135
139
|
await this.manager.telemetry.track({
|
|
136
140
|
event: "command:init:start",
|
|
137
141
|
repository: this.options.repository,
|
|
@@ -172,7 +176,7 @@ export class SliceMachineInitProcess {
|
|
|
172
176
|
await this.createNewRepository();
|
|
173
177
|
}
|
|
174
178
|
|
|
175
|
-
await this.
|
|
179
|
+
await this.pushDataToPrismic();
|
|
176
180
|
await this.initializeProject();
|
|
177
181
|
await this.initializePlugins();
|
|
178
182
|
} catch (error) {
|
|
@@ -299,8 +303,9 @@ export class SliceMachineInitProcess {
|
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
305
|
}
|
|
302
|
-
} catch {
|
|
303
|
-
//
|
|
306
|
+
} catch (error) {
|
|
307
|
+
// Only track this error with Sentry, it's only the final convenience message
|
|
308
|
+
await this.trackSentryError(error);
|
|
304
309
|
}
|
|
305
310
|
}
|
|
306
311
|
|
|
@@ -315,8 +320,6 @@ export class SliceMachineInitProcess {
|
|
|
315
320
|
this.manager.customTypes.readCustomTypeLibrary(),
|
|
316
321
|
this.readDocuments(),
|
|
317
322
|
]);
|
|
318
|
-
|
|
319
|
-
// If repository exists, and there's anything to push
|
|
320
323
|
if (
|
|
321
324
|
slices.length > 0 ||
|
|
322
325
|
ctLibrary.ids.length > 0 ||
|
|
@@ -324,11 +327,6 @@ export class SliceMachineInitProcess {
|
|
|
324
327
|
) {
|
|
325
328
|
return true;
|
|
326
329
|
}
|
|
327
|
-
|
|
328
|
-
// If repository exists, and there might be things to pull
|
|
329
|
-
if (ctLibrary.ids.length === 0) {
|
|
330
|
-
return true;
|
|
331
|
-
}
|
|
332
330
|
} catch (e) {
|
|
333
331
|
return true;
|
|
334
332
|
}
|
|
@@ -336,13 +334,17 @@ export class SliceMachineInitProcess {
|
|
|
336
334
|
return false;
|
|
337
335
|
}
|
|
338
336
|
|
|
339
|
-
protected trackError = (error: unknown): Promise<void> => {
|
|
337
|
+
protected trackError = async (error: unknown): Promise<void> => {
|
|
338
|
+
await this.trackSentryError(error);
|
|
339
|
+
await this.trackTelemetryError(error);
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
protected trackTelemetryError = async (error: unknown): Promise<void> => {
|
|
340
343
|
// Transform error to string and prevent hitting Segment 500kb API limit or sending ridiculously long trace
|
|
341
344
|
const safeError = (
|
|
342
345
|
error instanceof Error ? error.message : `${error}`
|
|
343
346
|
).slice(0, 512);
|
|
344
|
-
|
|
345
|
-
return this.manager.telemetry.track({
|
|
347
|
+
await this.manager.telemetry.track({
|
|
346
348
|
event: "command:init:end",
|
|
347
349
|
framework: this.context.framework?.sliceMachineTelemetryID ?? "unknown",
|
|
348
350
|
repository: this.context.repository?.domain || "",
|
|
@@ -351,6 +353,15 @@ export class SliceMachineInitProcess {
|
|
|
351
353
|
});
|
|
352
354
|
};
|
|
353
355
|
|
|
356
|
+
protected trackSentryError = async (error: unknown): Promise<void> => {
|
|
357
|
+
await updateSentryContext({
|
|
358
|
+
manager: this.manager,
|
|
359
|
+
repositoryName: this.context.repository?.domain || "",
|
|
360
|
+
framework: this.context.framework?.sliceMachineTelemetryID ?? "unknown",
|
|
361
|
+
});
|
|
362
|
+
trackSentryError(error);
|
|
363
|
+
};
|
|
364
|
+
|
|
354
365
|
protected async copyStarter(): Promise<void> {
|
|
355
366
|
const dir = await this.getStarterDirectoryName();
|
|
356
367
|
|
|
@@ -1099,10 +1110,10 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
1099
1110
|
return { signature, documents, directoryPath: documentsDirectoryPath };
|
|
1100
1111
|
}
|
|
1101
1112
|
|
|
1102
|
-
protected
|
|
1113
|
+
protected pushDataToPrismic(): Promise<void> {
|
|
1103
1114
|
return listrRun([
|
|
1104
1115
|
{
|
|
1105
|
-
title: "
|
|
1116
|
+
title: "Pushing data to Prismic...",
|
|
1106
1117
|
task: (_, parentTask) =>
|
|
1107
1118
|
listr([
|
|
1108
1119
|
{
|
|
@@ -1198,7 +1209,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
1198
1209
|
task: async (_, task) => {
|
|
1199
1210
|
assertExists(
|
|
1200
1211
|
this.context.repository,
|
|
1201
|
-
"Repository selection must be available through context to run `
|
|
1212
|
+
"Repository selection must be available through context to run `pushDataToPrismic`",
|
|
1202
1213
|
);
|
|
1203
1214
|
|
|
1204
1215
|
try {
|
|
@@ -1208,6 +1219,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
1208
1219
|
documentsRead === undefined ||
|
|
1209
1220
|
documentsRead.documents.length === 0
|
|
1210
1221
|
) {
|
|
1222
|
+
parentTask.title = "Pushed data to Prismic";
|
|
1211
1223
|
task.skip("No document to push");
|
|
1212
1224
|
|
|
1213
1225
|
return;
|
|
@@ -1249,7 +1261,9 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
1249
1261
|
});
|
|
1250
1262
|
|
|
1251
1263
|
task.title = "Pushed all documents";
|
|
1264
|
+
parentTask.title = "Pushed data to Prismic";
|
|
1252
1265
|
} catch {
|
|
1266
|
+
parentTask.title = "Pushed data to Prismic";
|
|
1253
1267
|
task.skip("No document to push");
|
|
1254
1268
|
|
|
1255
1269
|
return;
|
|
@@ -1271,41 +1285,7 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
1271
1285
|
}
|
|
1272
1286
|
|
|
1273
1287
|
task.title = "Cleaned up data push artifacts";
|
|
1274
|
-
|
|
1275
|
-
},
|
|
1276
|
-
{
|
|
1277
|
-
title: "Pulling existing types...",
|
|
1278
|
-
task: async (_, task) => {
|
|
1279
|
-
const { ids, errors } =
|
|
1280
|
-
await this.manager.customTypes.readCustomTypeLibrary();
|
|
1281
|
-
|
|
1282
|
-
if (errors.length > 0) {
|
|
1283
|
-
// TODO: Provide better error message.
|
|
1284
|
-
throw new Error(
|
|
1285
|
-
`Failed to read custom type libraries: ${errors.join(
|
|
1286
|
-
", ",
|
|
1287
|
-
)}`,
|
|
1288
|
-
);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
if (ids && ids.length > 0) {
|
|
1292
|
-
task.skip("Types already exists");
|
|
1293
|
-
parentTask.title = "Synced data with Prismic";
|
|
1294
|
-
|
|
1295
|
-
return;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
const remoteTypes =
|
|
1299
|
-
await this.manager.customTypes.fetchRemoteCustomTypes();
|
|
1300
|
-
|
|
1301
|
-
await Promise.all(
|
|
1302
|
-
remoteTypes.map(async (model) => {
|
|
1303
|
-
await this.manager.customTypes.createCustomType({ model });
|
|
1304
|
-
}),
|
|
1305
|
-
);
|
|
1306
|
-
|
|
1307
|
-
task.title = "Pulled existing types";
|
|
1308
|
-
parentTask.title = "Synced data with Prismic";
|
|
1288
|
+
parentTask.title = "Pushed data to Prismic";
|
|
1309
1289
|
},
|
|
1310
1290
|
},
|
|
1311
1291
|
]),
|
package/src/constants.ts
CHANGED
|
@@ -4,3 +4,6 @@ export const START_SCRIPT_VALUE = "start-slicemachine";
|
|
|
4
4
|
export const GIGET_PROVIDER = "github";
|
|
5
5
|
export const GIGET_ORGANIZATION = "prismicio-community";
|
|
6
6
|
export const SLICE_MACHINE_INIT_USER_AGENT = "slice-machine-init";
|
|
7
|
+
export const SENTRY_EXPRESS_DSN =
|
|
8
|
+
import.meta.env.VITE_SENTRY_EXPRESS_DSN ||
|
|
9
|
+
"https://d3e69d5189266d8d7f60f71ccc9353fc@o146123.ingest.sentry.io/4505917981982720";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks whether or not Sentry is enabled.
|
|
3
|
+
*
|
|
4
|
+
* Sentry is enabled automatically in production but can be disabled by setting
|
|
5
|
+
* `VITE_ENABLE_SENTRY` to `false`.
|
|
6
|
+
*
|
|
7
|
+
* @returns Whether or not Sentry is enabled.
|
|
8
|
+
*/
|
|
9
|
+
export const checkIsSentryEnabled = (): boolean =>
|
|
10
|
+
import.meta.env.VITE_ENABLE_SENTRY === undefined
|
|
11
|
+
? import.meta.env.PROD
|
|
12
|
+
: import.meta.env.VITE_ENABLE_SENTRY === "true";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Sentry from "@sentry/node";
|
|
2
|
+
|
|
3
|
+
import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
|
|
4
|
+
|
|
5
|
+
export function trackSentryError(error: unknown): void {
|
|
6
|
+
if (!checkIsSentryEnabled()) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
Sentry.captureException(error, {
|
|
11
|
+
...(error instanceof Error ? { extra: { cause: error.cause } } : {}),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as Sentry from "@sentry/node";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
|
|
4
|
+
import { SENTRY_EXPRESS_DSN } from "../constants";
|
|
5
|
+
import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
|
|
6
|
+
import { version } from "../../package.json";
|
|
7
|
+
|
|
8
|
+
export function setupSentry(): void {
|
|
9
|
+
if (!checkIsSentryEnabled()) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const isStableVersion =
|
|
14
|
+
semver.prerelease(version) === null && semver.lte("0.1.0", version);
|
|
15
|
+
|
|
16
|
+
Sentry.init({
|
|
17
|
+
dsn: SENTRY_EXPRESS_DSN,
|
|
18
|
+
release: version,
|
|
19
|
+
environment: isStableVersion
|
|
20
|
+
? import.meta.env.MODE || "production"
|
|
21
|
+
: "alpha",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Sentry from "@sentry/node";
|
|
2
|
+
|
|
3
|
+
import { PrismicUserProfile, SliceMachineManager } from "@slicemachine/manager";
|
|
4
|
+
import { checkIsSentryEnabled } from "./checkIsSentryEnabled";
|
|
5
|
+
|
|
6
|
+
type UpdateSentryContextArgs = {
|
|
7
|
+
manager: SliceMachineManager;
|
|
8
|
+
repositoryName: string;
|
|
9
|
+
framework: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export async function updateSentryContext({
|
|
13
|
+
manager,
|
|
14
|
+
repositoryName,
|
|
15
|
+
framework,
|
|
16
|
+
}: UpdateSentryContextArgs): Promise<void> {
|
|
17
|
+
if (!checkIsSentryEnabled()) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let userProfile: PrismicUserProfile | undefined;
|
|
22
|
+
try {
|
|
23
|
+
userProfile = await manager.user.getProfile();
|
|
24
|
+
} catch {
|
|
25
|
+
// User is not logged in, it doesn't matter
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (userProfile) {
|
|
29
|
+
Sentry.setUser({ id: userProfile.shortId });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (repositoryName) {
|
|
33
|
+
Sentry.setTag("repository", repositoryName);
|
|
34
|
+
Sentry.setContext("Repository Data", {
|
|
35
|
+
name: repositoryName,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (framework) {
|
|
40
|
+
Sentry.setTag("framework", framework);
|
|
41
|
+
}
|
|
42
|
+
}
|