@slicemachine/init 0.1.1-dev-plugins.11 → 0.1.1-dev-plugins.12
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/README.md +107 -0
- package/dist/SliceMachineInitProcess.cjs +17 -7
- package/dist/SliceMachineInitProcess.cjs.map +1 -1
- package/dist/SliceMachineInitProcess.js +17 -7
- package/dist/SliceMachineInitProcess.js.map +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/settings.cjs +1 -1
- package/dist/__node_modules/@nodelib/fs.walk/out/settings.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 +1 -1
- package/dist/__node_modules/fast-glob/out/readers/reader.js +1 -1
- 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/packages/init/package.json.cjs +1 -1
- package/dist/packages/init/package.json.js +1 -1
- package/package.json +6 -5
- package/src/SliceMachineInitProcess.ts +36 -12
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const name = "@slicemachine/init";
|
|
4
|
-
const version = "0.1.1-dev-plugins.
|
|
4
|
+
const version = "0.1.1-dev-plugins.12";
|
|
5
5
|
exports.name = name;
|
|
6
6
|
exports.version = version;
|
|
7
7
|
//# sourceMappingURL=package.json.cjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slicemachine/init",
|
|
3
|
-
"version": "0.1.1-dev-plugins.
|
|
3
|
+
"version": "0.1.1-dev-plugins.12",
|
|
4
4
|
"description": "Init Prismic Slice Machine in your project",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"lint": "eslint --ext .js,.ts .",
|
|
44
44
|
"prepare": "npm run build",
|
|
45
45
|
"size": "size-limit",
|
|
46
|
-
"test": "npm run lint && npm run unit && npm run build && npm run size",
|
|
46
|
+
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
|
|
47
|
+
"types": "tsc --noEmit",
|
|
47
48
|
"unit": "vitest run --coverage",
|
|
48
49
|
"unit:watch": "vitest watch",
|
|
49
50
|
"depcheck": "depcheck --config=.depcheckrc"
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"dependencies": {
|
|
52
53
|
"@antfu/ni": "^0.18.8",
|
|
53
54
|
"@lihbr/listr-update-renderer": "^0.5.3",
|
|
54
|
-
"@slicemachine/manager": "0.1.1-dev-plugins.
|
|
55
|
+
"@slicemachine/manager": "0.1.1-dev-plugins.12",
|
|
55
56
|
"chalk": "^4.1.2",
|
|
56
57
|
"execa": "^6.1.0",
|
|
57
58
|
"globby": "^13.1.3",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@size-limit/preset-small-lib": "^8.1.0",
|
|
67
|
-
"@slicemachine/plugin-kit": "
|
|
68
|
+
"@slicemachine/plugin-kit": "0.1.8-dev-plugins.12",
|
|
68
69
|
"@types/listr": "^0.14.4",
|
|
69
70
|
"@types/prompts": "^2.4.2",
|
|
70
71
|
"@types/semver": "^7.3.13",
|
|
@@ -88,5 +89,5 @@
|
|
|
88
89
|
"vite-plugin-sdk": "^0.1.0",
|
|
89
90
|
"vitest": "^0.26.1"
|
|
90
91
|
},
|
|
91
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "913882c4079ffcab3a72938b4be902470c1e3c32"
|
|
92
93
|
}
|
|
@@ -152,16 +152,25 @@ export class SliceMachineInitProcess {
|
|
|
152
152
|
);
|
|
153
153
|
|
|
154
154
|
try {
|
|
155
|
+
const apiEndpoints = this.manager.getAPIEndpoints();
|
|
156
|
+
const wroomHost = new URL(apiEndpoints.PrismicWroom).host;
|
|
157
|
+
|
|
158
|
+
const dashboardURL = new URL(
|
|
159
|
+
`https://${this.context.repository.domain}.${wroomHost}`,
|
|
160
|
+
)
|
|
161
|
+
.toString()
|
|
162
|
+
.replace(/\/$/, "");
|
|
163
|
+
const apiURL = new URL(
|
|
164
|
+
"./api/v2",
|
|
165
|
+
`https://${this.context.repository.domain}.cdn.${wroomHost}`,
|
|
166
|
+
).toString();
|
|
167
|
+
|
|
155
168
|
// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better
|
|
156
169
|
// eslint-disable-next-line no-console
|
|
157
170
|
console.log(`
|
|
158
171
|
YOUR REPOSITORY
|
|
159
|
-
Dashboard ${chalk.cyan(
|
|
160
|
-
|
|
161
|
-
)}
|
|
162
|
-
API ${chalk.cyan(
|
|
163
|
-
`https://${this.context.repository.domain}.cdn.prismic.io/api/v2`,
|
|
164
|
-
)}
|
|
172
|
+
Dashboard ${chalk.cyan(dashboardURL)}
|
|
173
|
+
API ${chalk.cyan(apiURL)}
|
|
165
174
|
|
|
166
175
|
RESOURCES
|
|
167
176
|
Documentation ${chalk.cyan(
|
|
@@ -934,21 +943,36 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
|
|
|
934
943
|
return;
|
|
935
944
|
}
|
|
936
945
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
946
|
+
// TODO: Replace `unknown` with a Prismic document type.
|
|
947
|
+
// The exact format is not know at this time, hence the `unknown`.
|
|
948
|
+
const documents: Record<string, unknown> = {};
|
|
949
|
+
|
|
950
|
+
await Promise.all(
|
|
951
|
+
documentsGlob.map(async (documentPath) => {
|
|
952
|
+
const filename = path.basename(documentPath, ".json");
|
|
940
953
|
const fileContent = await fs.readFile(
|
|
941
|
-
path.resolve(documentsDirectoryPath,
|
|
954
|
+
path.resolve(documentsDirectoryPath, documentPath),
|
|
942
955
|
"utf-8",
|
|
943
956
|
);
|
|
944
957
|
|
|
945
|
-
|
|
958
|
+
try {
|
|
959
|
+
// TOOD: Validate the contents of the JSON file and skip on invalid documents.
|
|
960
|
+
const parsedContents = JSON.parse(fileContent);
|
|
961
|
+
|
|
962
|
+
documents[filename] = parsedContents;
|
|
963
|
+
} catch {
|
|
964
|
+
// We prefer to manually allow console logs despite the app being a CLI to catch wild/unwanted console logs better
|
|
965
|
+
// eslint-disable-next-line no-console
|
|
966
|
+
console.log(
|
|
967
|
+
`Skipped document due to its invalid format: ${documentPath}`,
|
|
968
|
+
);
|
|
969
|
+
}
|
|
946
970
|
}),
|
|
947
971
|
);
|
|
948
972
|
|
|
949
973
|
await this.manager.prismicRepository.pushDocuments({
|
|
950
974
|
domain: this.context.repository.domain,
|
|
951
|
-
documents
|
|
975
|
+
documents,
|
|
952
976
|
signature,
|
|
953
977
|
});
|
|
954
978
|
|