@tinacms/scripts 1.3.1 → 1.3.3
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 +5 -5
- package/dist/index.js +79 -4
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This package provides the `tinacms-scripts` bin with the following commands:
|
|
4
4
|
|
|
5
|
-
| Command
|
|
6
|
-
|
|
|
7
|
-
| tinacms-scripts build
|
|
8
|
-
| tinacms-scripts watch
|
|
9
|
-
|
|
5
|
+
| Command | Description |
|
|
6
|
+
| ------------------------------ | --------------------------------------------------------------------------- |
|
|
7
|
+
| tinacms-scripts build | Builds the package for production use (i.e. uglified and without debugging) |
|
|
8
|
+
| tinacms-scripts watch | Watches the package for updates and rebuilds. |
|
|
9
|
+
| tinacms-scripts diff-tina-lock | Generate new tina-lock in current directory and check for changes |
|
|
10
10
|
|
|
11
11
|
The best way to work with this library is to run it from the root of the repository so all packages are watched in a single process. Refer to the top-level `package.json` for instructions.
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,18 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
}
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
21
33
|
var __export = (target, all) => {
|
|
22
34
|
for (var name in all)
|
|
23
35
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -41,14 +53,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
41
53
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
54
|
|
|
43
55
|
// src/index.ts
|
|
44
|
-
var
|
|
45
|
-
__export(
|
|
56
|
+
var index_exports = {};
|
|
57
|
+
__export(index_exports, {
|
|
46
58
|
buildIt: () => buildIt,
|
|
47
59
|
init: () => init,
|
|
48
60
|
run: () => run,
|
|
49
61
|
sequential: () => sequential
|
|
50
62
|
});
|
|
51
|
-
module.exports = __toCommonJS(
|
|
63
|
+
module.exports = __toCommonJS(index_exports);
|
|
52
64
|
var import_vite = require("vite");
|
|
53
65
|
var import_esbuild = require("esbuild");
|
|
54
66
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
@@ -56,10 +68,12 @@ var import_node_path = __toESM(require("path"));
|
|
|
56
68
|
var import_chokidar = __toESM(require("chokidar"));
|
|
57
69
|
var import_node_child_process = require("child_process");
|
|
58
70
|
var import_chalk = __toESM(require("chalk"));
|
|
71
|
+
var import_json_diff = __toESM(require("json-diff"));
|
|
59
72
|
var commander = __toESM(require("commander"));
|
|
60
73
|
var deepMerge = (target, source) => {
|
|
61
74
|
for (const key in source) {
|
|
62
|
-
if (!source.hasOwnProperty(key) || key === "__proto__" || key === "constructor")
|
|
75
|
+
if (!source.hasOwnProperty(key) || key === "__proto__" || key === "constructor")
|
|
76
|
+
continue;
|
|
63
77
|
if (source[key] instanceof Object && !Array.isArray(source[key]) && target.hasOwnProperty(key)) {
|
|
64
78
|
target[key] = deepMerge(target[key], source[key]);
|
|
65
79
|
} else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
|
|
@@ -158,6 +172,62 @@ var watch = () => {
|
|
|
158
172
|
});
|
|
159
173
|
});
|
|
160
174
|
};
|
|
175
|
+
var diffTinaLock = async () => {
|
|
176
|
+
if (!import_fs_extra.default.existsSync(`tina/tina-lock.json`)) {
|
|
177
|
+
console.error(
|
|
178
|
+
"No Tina lock found. Please run this command from the root of a Tina project \u274C"
|
|
179
|
+
);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
const tinaLock = JSON.parse(import_fs_extra.default.readFileSync(`tina/tina-lock.json`).toString());
|
|
183
|
+
if (!tinaLock.schema) {
|
|
184
|
+
console.error("No schema found in the Tina lock \u274C");
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
(0, import_node_child_process.exec)(
|
|
188
|
+
"pnpm exec tinacms dev --no-server",
|
|
189
|
+
{ cwd: process.cwd() },
|
|
190
|
+
(error, stdout, stderr) => {
|
|
191
|
+
if (error) {
|
|
192
|
+
console.error(`exec error: ${error} \u274C`);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (stdout) {
|
|
196
|
+
console.log(
|
|
197
|
+
stdout.split("\n").map((line) => `> ${line}`).join("\n")
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
if (stderr) {
|
|
201
|
+
console.error(`stderr: ${stderr}`);
|
|
202
|
+
}
|
|
203
|
+
const newTinaLock = JSON.parse(
|
|
204
|
+
import_fs_extra.default.readFileSync(`tina/tina-lock.json`).toString()
|
|
205
|
+
);
|
|
206
|
+
if (!newTinaLock.schema) {
|
|
207
|
+
console.error("No schema found in the new Tina lock \u274C");
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
const _a = tinaLock.schema, { version } = _a, schema = __objRest(_a, ["version"]);
|
|
211
|
+
const _b = newTinaLock.schema, { version: newVersion } = _b, newSchema = __objRest(_b, ["version"]);
|
|
212
|
+
const schemaDiff = import_json_diff.default.diffString(schema, newSchema);
|
|
213
|
+
if (schemaDiff) {
|
|
214
|
+
console.error("Unexpected change(s) to Tina schema \u274C");
|
|
215
|
+
console.log(schemaDiff);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
const graphqlDiff = import_json_diff.default.diffString(
|
|
219
|
+
tinaLock.graphql,
|
|
220
|
+
newTinaLock.graphql
|
|
221
|
+
);
|
|
222
|
+
if (graphqlDiff) {
|
|
223
|
+
console.error("Unexpected change(s) to Tina graphql schema \u274C");
|
|
224
|
+
console.log(graphqlDiff);
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
console.log("No changes found in Tina lock \u2705");
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
};
|
|
161
231
|
async function init(args) {
|
|
162
232
|
registerCommands([
|
|
163
233
|
{
|
|
@@ -175,6 +245,11 @@ async function init(args) {
|
|
|
175
245
|
command: "watch",
|
|
176
246
|
description: "Watch",
|
|
177
247
|
action: () => watch()
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
command: "diff-tina-lock",
|
|
251
|
+
description: "Compare the current schema for a tina project with newly generated schema",
|
|
252
|
+
action: () => diffTinaLock()
|
|
178
253
|
}
|
|
179
254
|
]);
|
|
180
255
|
program.usage("command [options]");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/scripts",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
"chalk": "^4.1.2",
|
|
18
18
|
"chokidar": "^3.6.0",
|
|
19
19
|
"commander": "^7.2.0",
|
|
20
|
-
"esbuild": "^0.
|
|
21
|
-
"fs-extra": "^11.
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
20
|
+
"esbuild": "^0.24.2",
|
|
21
|
+
"fs-extra": "^11.3.0",
|
|
22
|
+
"json-diff": "^1.0.6",
|
|
23
|
+
"tsup": "^8.3.6",
|
|
24
|
+
"typescript": "^5.7.3",
|
|
25
|
+
"vite": "^4.5.9"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
28
|
"build:all": "bin/tina-build build:all",
|