@tinacms/scripts 0.0.0-eb519f2-20241015053224 → 0.0.0-ece366b-20260804150807
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/__mocks__/styleMock.js +1 -1
- package/bin/tina-build +3 -1
- package/dist/chunk-Q2LW34XU.js +33 -0
- package/dist/index.js +404 -349
- package/dist/jest-runner.js +5 -42
- package/package.json +20 -11
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/__mocks__/styleMock.js
CHANGED
package/bin/tina-build
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
__spreadValues,
|
|
32
|
+
__objRest
|
|
33
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,65 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
var __export = (target, all) => {
|
|
22
|
-
for (var name in all)
|
|
23
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
-
};
|
|
25
|
-
var __copyProps = (to, from, except, desc) => {
|
|
26
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
-
for (let key of __getOwnPropNames(from))
|
|
28
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
-
}
|
|
31
|
-
return to;
|
|
32
|
-
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
35
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
36
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
37
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
38
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
39
|
-
mod
|
|
40
|
-
));
|
|
41
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadValues
|
|
4
|
+
} from "./chunk-Q2LW34XU.js";
|
|
42
5
|
|
|
43
6
|
// src/index.ts
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var import_node_child_process = require("child_process");
|
|
58
|
-
var import_chalk = __toESM(require("chalk"));
|
|
59
|
-
var commander = __toESM(require("commander"));
|
|
60
|
-
var deepMerge = (target, source) => {
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import { exec } from "child_process";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import chalk from "chalk";
|
|
11
|
+
import chokidar from "chokidar";
|
|
12
|
+
import commander from "commander";
|
|
13
|
+
import { build as esbuild } from "esbuild";
|
|
14
|
+
import fsExtra from "fs-extra";
|
|
15
|
+
import jsonDiff from "json-diff";
|
|
16
|
+
import { build } from "vite";
|
|
17
|
+
|
|
18
|
+
// src/utils.ts
|
|
19
|
+
function deepMerge(target, source) {
|
|
61
20
|
for (const key in source) {
|
|
62
|
-
if (!source.hasOwnProperty(key) || key === "__proto__" || key === "constructor")
|
|
21
|
+
if (!source.hasOwnProperty(key) || key === "__proto__" || key === "constructor")
|
|
22
|
+
continue;
|
|
63
23
|
if (source[key] instanceof Object && !Array.isArray(source[key]) && target.hasOwnProperty(key)) {
|
|
64
24
|
target[key] = deepMerge(target[key], source[key]);
|
|
65
25
|
} else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
|
|
@@ -71,323 +31,418 @@ var deepMerge = (target, source) => {
|
|
|
71
31
|
}
|
|
72
32
|
}
|
|
73
33
|
return target;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
34
|
+
}
|
|
35
|
+
async function sequential(items, callback) {
|
|
36
|
+
const accum = [];
|
|
37
|
+
if (!items) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const reducePromises = async (previous, endpoint) => {
|
|
41
|
+
const prev = await previous;
|
|
42
|
+
if (prev) accum.push(prev);
|
|
43
|
+
return callback(endpoint, accum.length);
|
|
44
|
+
};
|
|
45
|
+
const result = await items.reduce(reducePromises, Promise.resolve());
|
|
46
|
+
if (result) {
|
|
47
|
+
accum.push(result);
|
|
48
|
+
}
|
|
49
|
+
return accum;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/index.ts
|
|
53
|
+
var { outputFileSync } = fsExtra;
|
|
54
|
+
var BuildTina = class {
|
|
55
|
+
constructor(name) {
|
|
56
|
+
this.program = new commander.Command(name);
|
|
57
|
+
}
|
|
58
|
+
registerCommands(commands, noHelp = false) {
|
|
59
|
+
for (const command of commands) {
|
|
60
|
+
const options = command.options || [];
|
|
61
|
+
let newCmd = this.program.command(command.command, { hidden: noHelp }).description(command.description).action((...args) => {
|
|
62
|
+
command.action(...args);
|
|
63
|
+
});
|
|
64
|
+
if (command.alias) {
|
|
65
|
+
newCmd = newCmd.alias(command.alias);
|
|
66
|
+
}
|
|
67
|
+
newCmd.on("--help", () => {
|
|
68
|
+
if (command.examples) console.log(`
|
|
87
69
|
Examples:
|
|
88
70
|
${command.examples}`);
|
|
71
|
+
if (command.subCommands) {
|
|
72
|
+
console.log("\nCommands:");
|
|
73
|
+
const optionTag = " [options]";
|
|
74
|
+
for (const subcommand of command.subCommands) {
|
|
75
|
+
const commandStr = `${subcommand.command}${options.length ? optionTag : ""}`;
|
|
76
|
+
const padLength = Math.max(
|
|
77
|
+
...command.subCommands.map((sub) => sub.command.length)
|
|
78
|
+
) + optionTag.length;
|
|
79
|
+
console.log(
|
|
80
|
+
`${commandStr.padEnd(padLength)} ${subcommand.description}`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
console.log("");
|
|
85
|
+
});
|
|
86
|
+
for (const option of options) {
|
|
87
|
+
newCmd.option(option.name, option.description);
|
|
89
88
|
}
|
|
90
|
-
if (command.subCommands)
|
|
91
|
-
console.log("\nCommands:");
|
|
92
|
-
const optionTag = " [options]";
|
|
93
|
-
command.subCommands.forEach((subcommand, i2) => {
|
|
94
|
-
const commandStr = `${subcommand.command}${(subcommand.options || []).length ? optionTag : ""}`;
|
|
95
|
-
const padLength = Math.max(...command.subCommands.map((sub) => sub.command.length)) + optionTag.length;
|
|
96
|
-
console.log(
|
|
97
|
-
`${commandStr.padEnd(padLength)} ${subcommand.description}`
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
console.log("");
|
|
102
|
-
});
|
|
103
|
-
(command.options || []).forEach((option) => {
|
|
104
|
-
newCmd.option(option.name, option.description);
|
|
105
|
-
});
|
|
106
|
-
if (command.subCommands) {
|
|
107
|
-
registerCommands(command.subCommands, true);
|
|
89
|
+
if (command.subCommands) this.registerCommands(command.subCommands, true);
|
|
108
90
|
}
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
var run = async (args) => {
|
|
112
|
-
var _a;
|
|
113
|
-
if (args.dir) {
|
|
114
|
-
process.chdir(args.dir);
|
|
115
91
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
92
|
+
async run(args) {
|
|
93
|
+
var _a;
|
|
94
|
+
if (args.dir) process.chdir(args.dir);
|
|
95
|
+
let packageJson = null;
|
|
96
|
+
try {
|
|
97
|
+
const packageJsonContent = fs.readFileSync(
|
|
98
|
+
path.join(process.cwd(), "package.json")
|
|
99
|
+
);
|
|
100
|
+
packageJson = JSON.parse(packageJsonContent.toString());
|
|
101
|
+
} catch (err) {
|
|
102
|
+
const error = err;
|
|
103
|
+
console.error(`Failed to parse package.json: ${error.message}`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
if (["@tinacms/scripts", "@tinacms/webpack-helpers"].includes(
|
|
107
|
+
packageJson.name
|
|
108
|
+
)) {
|
|
109
|
+
console.info(`Skipping ${packageJson.name}`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const successMessage = `${chalk.blue(`${packageJson.name}`)} built in`;
|
|
113
|
+
console.time(successMessage);
|
|
114
|
+
const entries = ((_a = packageJson.buildConfig) == null ? void 0 : _a.entryPoints.map(
|
|
115
|
+
(ep) => {
|
|
116
|
+
if (typeof ep === "string") {
|
|
117
|
+
return { name: ep, target: "browser" };
|
|
118
|
+
}
|
|
119
|
+
return ep;
|
|
120
|
+
}
|
|
121
|
+
)) || [{ name: "src/index.ts", target: "browser" }];
|
|
122
|
+
try {
|
|
123
|
+
await sequential(entries, async (entry) => {
|
|
124
|
+
return this.buildPackage(entry, packageJson);
|
|
125
|
+
});
|
|
126
|
+
if (args.dir) console.timeEnd(successMessage);
|
|
127
|
+
} catch (err) {
|
|
128
|
+
const error = err;
|
|
129
|
+
console.error(`Failed to build ${packageJson.name}: ${error.message}`);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
123
132
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
watch() {
|
|
134
|
+
try {
|
|
135
|
+
exec("pnpm list -r --json", (error, stdout) => {
|
|
136
|
+
if (error) {
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
const json = JSON.parse(stdout);
|
|
140
|
+
const watchPaths = [];
|
|
141
|
+
for (const pkg of json) {
|
|
142
|
+
const pkgPath = "packages";
|
|
143
|
+
if (pkg.path.includes(pkgPath)) watchPaths.push(pkg.path);
|
|
144
|
+
}
|
|
145
|
+
chokidar.watch(
|
|
146
|
+
watchPaths.map((p) => path.join(p, "src", "**/*")),
|
|
147
|
+
{ ignored: ["**/spec/**/*", "node_modules"] }
|
|
148
|
+
).on("change", async (path2) => {
|
|
149
|
+
const changedPackagePath = watchPaths.find(
|
|
150
|
+
(p) => path2.startsWith(p)
|
|
151
|
+
);
|
|
152
|
+
await this.run({ dir: changedPackagePath });
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
} catch (err) {
|
|
156
|
+
const error = err;
|
|
157
|
+
console.error(`Failed to exec watch command: ${error.message}`);
|
|
158
|
+
process.exit(1);
|
|
133
159
|
}
|
|
134
|
-
} catch (e) {
|
|
135
|
-
console.log(`Error building ${packageJSON.name}`);
|
|
136
|
-
throw new Error(e);
|
|
137
160
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
161
|
+
diffTinaLock() {
|
|
162
|
+
if (!fs.existsSync(`tina/tina-lock.json`)) {
|
|
163
|
+
console.error(
|
|
164
|
+
"No Tina lock found. Please run this command from the root of a Tina project \u274C"
|
|
165
|
+
);
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
let tinaLock = null;
|
|
169
|
+
try {
|
|
170
|
+
const tinaLockContent = fs.readFileSync(
|
|
171
|
+
"tina/tina-lock.json"
|
|
172
|
+
);
|
|
173
|
+
tinaLock = JSON.parse(tinaLockContent.toString());
|
|
174
|
+
if (!tinaLock.schema) {
|
|
175
|
+
throw new Error("No schema found in the Tina lock \u274C");
|
|
176
|
+
}
|
|
177
|
+
} catch (err) {
|
|
178
|
+
const error = err;
|
|
179
|
+
console.error(`Failed to parse tina/tina-lock.json: ${error.message}`);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
try {
|
|
183
|
+
exec(
|
|
184
|
+
"pnpm exec tinacms dev --no-server",
|
|
185
|
+
{ cwd: process.cwd() },
|
|
186
|
+
(error, stdout, stderr) => {
|
|
187
|
+
if (error) {
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
if (stderr) {
|
|
191
|
+
throw new Error(stderr);
|
|
192
|
+
}
|
|
193
|
+
if (stdout) {
|
|
194
|
+
console.log(
|
|
195
|
+
stdout.split("\n").map((line) => `> ${line}`).join("\n")
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
let newTinaLock = null;
|
|
199
|
+
try {
|
|
200
|
+
const newTinaLockContent = fs.readFileSync(
|
|
201
|
+
"tina/tina-lock.json"
|
|
202
|
+
);
|
|
203
|
+
newTinaLock = JSON.parse(newTinaLockContent.toString());
|
|
204
|
+
if (!newTinaLock.schema) {
|
|
205
|
+
throw new Error("No schema found in the new Tina lock \u274C");
|
|
206
|
+
}
|
|
207
|
+
} catch (err) {
|
|
208
|
+
const error2 = err;
|
|
209
|
+
console.error(
|
|
210
|
+
`Failed to parse tina/tina-lock.json: ${error2.message}`
|
|
211
|
+
);
|
|
212
|
+
throw error2;
|
|
213
|
+
}
|
|
214
|
+
const _a = tinaLock.schema, { version } = _a, schema = __objRest(_a, ["version"]);
|
|
215
|
+
const _b = newTinaLock.schema, { version: newVersion } = _b, newSchema = __objRest(_b, ["version"]);
|
|
216
|
+
const schemaDiff = jsonDiff.diffString(schema, newSchema);
|
|
217
|
+
if (schemaDiff) {
|
|
218
|
+
console.error("Unexpected change(s) to Tina schema \u274C");
|
|
219
|
+
console.error(schemaDiff);
|
|
220
|
+
throw new Error("Unexpected change(s) to Tina schema \u274C");
|
|
221
|
+
}
|
|
222
|
+
const graphqlDiff = jsonDiff.diffString(
|
|
223
|
+
tinaLock.graphql,
|
|
224
|
+
newTinaLock.graphql
|
|
225
|
+
);
|
|
226
|
+
if (graphqlDiff) {
|
|
227
|
+
console.error("Unexpected change(s) to Tina graphql schema \u274C");
|
|
228
|
+
console.error(graphqlDiff);
|
|
229
|
+
throw new Error("Unexpected change(s) to Tina grahpql schema \u274C");
|
|
230
|
+
}
|
|
231
|
+
console.log("No changes found in Tina lock \u2705");
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
} catch (err) {
|
|
235
|
+
const error = err;
|
|
236
|
+
console.error(`Failed to start dev server: ${error.message}`);
|
|
237
|
+
process.exit(1);
|
|
144
238
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
239
|
+
}
|
|
240
|
+
init(args) {
|
|
241
|
+
this.registerCommands([
|
|
242
|
+
{
|
|
243
|
+
command: "build",
|
|
244
|
+
description: "Build",
|
|
245
|
+
options: [
|
|
246
|
+
{
|
|
247
|
+
name: "--watch",
|
|
248
|
+
description: "Watch for file changes and rebuild"
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
action: (options) => this.run(options)
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
command: "watch",
|
|
255
|
+
description: "Watch",
|
|
256
|
+
action: () => this.watch()
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
command: "diff-tina-lock",
|
|
260
|
+
description: "Compare the current schema for a tina project with newly generated schema",
|
|
261
|
+
action: () => this.diffTinaLock()
|
|
150
262
|
}
|
|
263
|
+
]);
|
|
264
|
+
this.program.usage("command [options]");
|
|
265
|
+
this.program.on("command:*", function() {
|
|
266
|
+
console.error(
|
|
267
|
+
`Invalid command: ${args.join(" ")}
|
|
268
|
+
See --help for a list of available commands.`
|
|
269
|
+
);
|
|
270
|
+
process.exit(1);
|
|
151
271
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const changedPackagePath = watchPaths.find((p) => path2.startsWith(p));
|
|
157
|
-
await run({ dir: changedPackagePath });
|
|
272
|
+
this.program.on("--help", function() {
|
|
273
|
+
console.log(
|
|
274
|
+
'You can get help on any command with "-h" or "--help".\ne.g: "forestry types:gen --help"'
|
|
275
|
+
);
|
|
158
276
|
});
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
async function init(args) {
|
|
162
|
-
registerCommands([
|
|
163
|
-
{
|
|
164
|
-
command: "build",
|
|
165
|
-
description: "Build",
|
|
166
|
-
options: [
|
|
167
|
-
{
|
|
168
|
-
name: "--watch",
|
|
169
|
-
description: "Watch for file changes and rebuild"
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
|
-
action: (options) => run(options)
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
command: "watch",
|
|
176
|
-
description: "Watch",
|
|
177
|
-
action: () => watch()
|
|
277
|
+
if (!process.argv.slice(2).length) {
|
|
278
|
+
this.program.help();
|
|
178
279
|
}
|
|
179
|
-
|
|
180
|
-
program.usage("command [options]");
|
|
181
|
-
program.on("command:*", function() {
|
|
182
|
-
console.error(
|
|
183
|
-
"Invalid command: %s\nSee --help for a list of available commands.",
|
|
184
|
-
args.join(" ")
|
|
185
|
-
);
|
|
186
|
-
process.exit(1);
|
|
187
|
-
});
|
|
188
|
-
program.on("--help", function() {
|
|
189
|
-
console.log(`
|
|
190
|
-
You can get help on any command with "-h" or "--help".
|
|
191
|
-
e.g: "forestry types:gen --help"
|
|
192
|
-
`);
|
|
193
|
-
});
|
|
194
|
-
if (!process.argv.slice(2).length) {
|
|
195
|
-
program.help();
|
|
280
|
+
this.program.parse(args);
|
|
196
281
|
}
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
var buildIt = async (entryPoint, packageJSON) => {
|
|
200
|
-
const entry = typeof entryPoint === "string" ? entryPoint : entryPoint.name;
|
|
201
|
-
const target = typeof entryPoint === "string" ? "browser" : entryPoint.target;
|
|
202
|
-
const deps = packageJSON.dependencies;
|
|
203
|
-
const peerDeps = packageJSON.peerDependencies;
|
|
204
|
-
const external = Object.keys(__spreadValues(__spreadValues({}, deps), peerDeps));
|
|
205
|
-
const globals = {};
|
|
206
|
-
const out = (entry2) => {
|
|
207
|
-
const { dir, name } = import_node_path.default.parse(entry2);
|
|
282
|
+
getOutputPaths(entry) {
|
|
283
|
+
const { dir, name } = path.parse(entry);
|
|
208
284
|
const outdir = dir.replace("src", "dist");
|
|
209
285
|
const outfile = name;
|
|
210
|
-
const relativeOutfile =
|
|
286
|
+
const relativeOutfile = path.join(
|
|
211
287
|
outdir.split("/").map(() => "..").join("/"),
|
|
212
288
|
dir,
|
|
213
289
|
name
|
|
214
290
|
);
|
|
215
291
|
return { outdir, outfile, relativeOutfile };
|
|
216
|
-
};
|
|
217
|
-
const outInfo = out(entry);
|
|
218
|
-
if (["@tinacms/app"].includes(packageJSON.name)) {
|
|
219
|
-
console.log("skipping @tinacms/app");
|
|
220
|
-
return;
|
|
221
292
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
outfile: outInfo.outfile ? import_node_path.default.join(process.cwd(), "dist", `${outInfo.outfile}.js`) : import_node_path.default.join(process.cwd(), "dist", "index.js"),
|
|
235
|
-
external: external.filter(
|
|
236
|
-
(item) => !packageJSON.buildConfig.entryPoints[0].bundle.includes(item)
|
|
237
|
-
)
|
|
238
|
-
});
|
|
239
|
-
await (0, import_esbuild.build)({
|
|
240
|
-
entryPoints: [import_node_path.default.join(process.cwd(), entry)],
|
|
241
|
-
bundle: true,
|
|
242
|
-
platform: "node",
|
|
243
|
-
target: "es2020",
|
|
244
|
-
format: "esm",
|
|
245
|
-
outfile: outInfo.outfile ? import_node_path.default.join(process.cwd(), "dist", `${outInfo.outfile}.mjs`) : import_node_path.default.join(process.cwd(), "dist", "index.mjs"),
|
|
246
|
-
external
|
|
247
|
-
});
|
|
248
|
-
} else if (["@tinacms/mdx"].includes(packageJSON.name)) {
|
|
249
|
-
const peerDeps2 = packageJSON.peerDependencies;
|
|
250
|
-
await (0, import_esbuild.build)({
|
|
251
|
-
entryPoints: [import_node_path.default.join(process.cwd(), entry)],
|
|
252
|
-
bundle: true,
|
|
253
|
-
platform: "node",
|
|
254
|
-
// FIXME: no idea why but even though I'm on node14 it doesn't like
|
|
255
|
-
// the syntax for optional chaining, should be supported on 14
|
|
256
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
|
|
257
|
-
target: "node12",
|
|
258
|
-
format: "cjs",
|
|
259
|
-
outfile: import_node_path.default.join(process.cwd(), "dist", "index.js"),
|
|
260
|
-
external: Object.keys(__spreadValues({}, peerDeps2))
|
|
261
|
-
});
|
|
262
|
-
await (0, import_esbuild.build)({
|
|
263
|
-
entryPoints: [import_node_path.default.join(process.cwd(), entry)],
|
|
264
|
-
bundle: true,
|
|
265
|
-
platform: "node",
|
|
266
|
-
target: "es2020",
|
|
267
|
-
format: "esm",
|
|
268
|
-
outfile: import_node_path.default.join(process.cwd(), "dist", "index.mjs"),
|
|
269
|
-
// Bundle dependencies, the remark ecosystem only publishes ES modules
|
|
270
|
-
// and includes "development" export maps which actually throw errors during
|
|
271
|
-
// development, which we don't want to expose our users to.
|
|
272
|
-
external: Object.keys(__spreadValues({}, peerDeps2))
|
|
273
|
-
});
|
|
274
|
-
await (0, import_esbuild.build)({
|
|
275
|
-
entryPoints: [import_node_path.default.join(process.cwd(), entry)],
|
|
276
|
-
bundle: true,
|
|
277
|
-
platform: "browser",
|
|
278
|
-
target: "es2020",
|
|
279
|
-
format: "esm",
|
|
280
|
-
outfile: import_node_path.default.join(process.cwd(), "dist", "index.browser.mjs"),
|
|
281
|
-
// Bundle dependencies, the remark ecosystem only publishes ES modules
|
|
282
|
-
// and includes "development" export maps which actually throw errors during
|
|
283
|
-
// development, which we don't want to expose our users to.
|
|
284
|
-
external: Object.keys(__spreadValues({}, peerDeps2))
|
|
285
|
-
});
|
|
286
|
-
} else {
|
|
287
|
-
await (0, import_esbuild.build)({
|
|
288
|
-
entryPoints: [import_node_path.default.join(process.cwd(), entry)],
|
|
289
|
-
bundle: true,
|
|
290
|
-
platform: "node",
|
|
291
|
-
outfile: import_node_path.default.join(process.cwd(), "dist", `${outInfo.outfile}.js`),
|
|
292
|
-
external,
|
|
293
|
-
target: "node12"
|
|
294
|
-
});
|
|
293
|
+
async buildPackage(entryPoint, packageJSON) {
|
|
294
|
+
const entry = entryPoint.name;
|
|
295
|
+
const target = entryPoint.target;
|
|
296
|
+
const extension = path.extname(entry);
|
|
297
|
+
const deps = packageJSON.dependencies;
|
|
298
|
+
const peerDeps = packageJSON.peerDependencies;
|
|
299
|
+
const external = Object.keys(__spreadValues(__spreadValues({}, deps), peerDeps));
|
|
300
|
+
const outInfo = this.getOutputPaths(entry);
|
|
301
|
+
const globals = {};
|
|
302
|
+
if (["@tinacms/app"].includes(packageJSON.name)) {
|
|
303
|
+
console.log("skipping @tinacms/app");
|
|
304
|
+
return;
|
|
295
305
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
external.forEach((ext) => globals[ext] = "NOOP");
|
|
307
|
+
const isExternal = (id) => external.some((dep) => id === dep || id.startsWith(`${dep}/`));
|
|
308
|
+
if (target === "node") {
|
|
309
|
+
if (["@tinacms/graphql", "@tinacms/datalayer"].includes(packageJSON.name)) {
|
|
310
|
+
await esbuild({
|
|
311
|
+
entryPoints: [path.join(process.cwd(), entry)],
|
|
312
|
+
bundle: true,
|
|
313
|
+
platform: "node",
|
|
314
|
+
target: "esnext",
|
|
315
|
+
format: "esm",
|
|
316
|
+
outfile: path.join(
|
|
317
|
+
process.cwd(),
|
|
318
|
+
"dist",
|
|
319
|
+
`${outInfo.outfile ? outInfo.outfile : "index"}.js`
|
|
320
|
+
),
|
|
321
|
+
external: external.filter((item) => {
|
|
322
|
+
const entryPoint2 = packageJSON.buildConfig.entryPoints[0];
|
|
323
|
+
if (typeof entryPoint2 === "string") return false;
|
|
324
|
+
return !entryPoint2.bundle.includes(item);
|
|
325
|
+
})
|
|
326
|
+
});
|
|
327
|
+
await esbuild({
|
|
328
|
+
entryPoints: [path.join(process.cwd(), entry)],
|
|
329
|
+
bundle: true,
|
|
330
|
+
platform: "node",
|
|
331
|
+
target: "esnext",
|
|
332
|
+
format: "esm",
|
|
333
|
+
outfile: path.join(
|
|
334
|
+
process.cwd(),
|
|
335
|
+
"dist",
|
|
336
|
+
`${outInfo.outfile ? outInfo.outfile : "index"}.js`
|
|
337
|
+
),
|
|
338
|
+
external
|
|
339
|
+
});
|
|
340
|
+
} else if (["@tinacms/mdx"].includes(packageJSON.name)) {
|
|
341
|
+
const peerDeps2 = packageJSON.peerDependencies;
|
|
342
|
+
await esbuild({
|
|
343
|
+
entryPoints: [path.join(process.cwd(), entry)],
|
|
344
|
+
bundle: true,
|
|
345
|
+
platform: "node",
|
|
346
|
+
target: "esnext",
|
|
347
|
+
format: "esm",
|
|
348
|
+
outfile: path.join(process.cwd(), "dist", "index.js"),
|
|
349
|
+
external: Object.keys(__spreadValues({}, peerDeps2))
|
|
350
|
+
});
|
|
351
|
+
await esbuild({
|
|
352
|
+
entryPoints: [path.join(process.cwd(), entry)],
|
|
353
|
+
bundle: true,
|
|
354
|
+
platform: "browser",
|
|
355
|
+
target: "esnext",
|
|
356
|
+
format: "esm",
|
|
357
|
+
outfile: path.join(process.cwd(), "dist", "index.browser.js"),
|
|
358
|
+
// Bundle dependencies, the remark ecosystem only publishes ES modules
|
|
359
|
+
// and includes "development" export maps which actually throw errors during
|
|
360
|
+
// development, which we don't want to expose our users to.
|
|
361
|
+
external: Object.keys(__spreadValues({}, peerDeps2))
|
|
362
|
+
});
|
|
363
|
+
} else {
|
|
364
|
+
await esbuild({
|
|
365
|
+
entryPoints: [path.join(process.cwd(), entry)],
|
|
366
|
+
bundle: true,
|
|
367
|
+
platform: "node",
|
|
368
|
+
target: "esnext",
|
|
369
|
+
format: "esm",
|
|
370
|
+
outfile: path.join(process.cwd(), "dist", `${outInfo.outfile}.js`),
|
|
371
|
+
external
|
|
372
|
+
});
|
|
312
373
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
374
|
+
fs.writeFileSync(
|
|
375
|
+
path.join(
|
|
376
|
+
process.cwd(),
|
|
377
|
+
"dist",
|
|
378
|
+
entry.replace("src/", "").replace(extension, ".d.ts")
|
|
379
|
+
),
|
|
380
|
+
`export * from "../${entry.replace(extension, "")}"`
|
|
381
|
+
);
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
const defaultBuildConfig = {
|
|
385
|
+
resolve: {
|
|
386
|
+
alias: {
|
|
387
|
+
"@toolkit": path.resolve(process.cwd(), "src/toolkit"),
|
|
388
|
+
"@tinacms/toolkit": path.resolve(
|
|
389
|
+
process.cwd(),
|
|
390
|
+
"src/toolkit/index.ts"
|
|
391
|
+
),
|
|
392
|
+
"@utils": path.resolve(process.cwd(), "src/utils")
|
|
322
393
|
}
|
|
323
394
|
},
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
warn(warning);
|
|
395
|
+
build: {
|
|
396
|
+
minify: false,
|
|
397
|
+
assetsInlineLimit: 0,
|
|
398
|
+
lib: {
|
|
399
|
+
entry: path.resolve(process.cwd(), entry),
|
|
400
|
+
name: packageJSON.name,
|
|
401
|
+
formats: ["es"],
|
|
402
|
+
fileName: () => `${outInfo.outfile}.js`
|
|
335
403
|
},
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
404
|
+
outDir: outInfo.outdir,
|
|
405
|
+
emptyOutDir: false,
|
|
406
|
+
// We build multiple files in to the dir.
|
|
407
|
+
sourcemap: false,
|
|
408
|
+
rollupOptions: {
|
|
409
|
+
onwarn(warning, warn) {
|
|
410
|
+
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
warn(warning);
|
|
414
|
+
},
|
|
415
|
+
plugins: [],
|
|
416
|
+
/**
|
|
417
|
+
* For some reason Rollup thinks it needs a global, though
|
|
418
|
+
* I'm pretty sure it doesn't, since everything works
|
|
419
|
+
*
|
|
420
|
+
* By setting a global for each external dep we're silencing these warnings
|
|
421
|
+
* No name was provided for external module in output.globals
|
|
422
|
+
*
|
|
423
|
+
* They don't occur for es builds, only UMD and I can't quite find
|
|
424
|
+
* an authoritative response on wny they're needed or how they're
|
|
425
|
+
* used in the UMD context.
|
|
426
|
+
*
|
|
427
|
+
* https://github.com/rollup/rollup/issues/1514#issuecomment-321877507
|
|
428
|
+
* https://github.com/rollup/rollup/issues/1169#issuecomment-268815735
|
|
429
|
+
*/
|
|
430
|
+
output: {
|
|
431
|
+
globals
|
|
432
|
+
},
|
|
433
|
+
external: isExternal
|
|
434
|
+
}
|
|
358
435
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return true;
|
|
368
|
-
};
|
|
369
|
-
var sequential = async (items, callback) => {
|
|
370
|
-
const accum = [];
|
|
371
|
-
if (!items) {
|
|
372
|
-
return [];
|
|
373
|
-
}
|
|
374
|
-
const reducePromises = async (previous, endpoint) => {
|
|
375
|
-
const prev = await previous;
|
|
376
|
-
if (prev) {
|
|
377
|
-
accum.push(prev);
|
|
378
|
-
}
|
|
379
|
-
return callback(endpoint, accum.length);
|
|
380
|
-
};
|
|
381
|
-
const result = await items.reduce(reducePromises, Promise.resolve());
|
|
382
|
-
if (result) {
|
|
383
|
-
accum.push(result);
|
|
436
|
+
};
|
|
437
|
+
const buildConfig = packageJSON.buildConfig ? deepMerge(defaultBuildConfig, packageJSON.buildConfig) : defaultBuildConfig;
|
|
438
|
+
await build(__spreadValues({}, buildConfig));
|
|
439
|
+
outputFileSync(
|
|
440
|
+
path.join(outInfo.outdir, `${outInfo.outfile}.d.ts`),
|
|
441
|
+
`export * from "${outInfo.relativeOutfile}"`
|
|
442
|
+
);
|
|
443
|
+
return true;
|
|
384
444
|
}
|
|
385
|
-
return accum;
|
|
386
445
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
init,
|
|
391
|
-
run,
|
|
392
|
-
sequential
|
|
393
|
-
});
|
|
446
|
+
export {
|
|
447
|
+
BuildTina
|
|
448
|
+
};
|
package/dist/jest-runner.js
CHANGED
|
@@ -1,55 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
import "./chunk-Q2LW34XU.js";
|
|
28
2
|
|
|
29
3
|
// src/jest-runner.ts
|
|
30
|
-
var jest_runner_exports = {};
|
|
31
|
-
__export(jest_runner_exports, {
|
|
32
|
-
default: () => jest_runner_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(jest_runner_exports);
|
|
35
|
-
var import_jest_plugin = __toESM(require("@sucrase/jest-plugin"));
|
|
36
4
|
var config = {
|
|
37
5
|
verbose: true,
|
|
38
6
|
transform: {
|
|
39
|
-
"
|
|
40
|
-
".(js)": "@tinacms/scripts/dist/jest-runner.js"
|
|
7
|
+
"^.+\\.[tj]sx?$": "babel-jest"
|
|
41
8
|
},
|
|
42
|
-
transformIgnorePatterns: [],
|
|
43
|
-
testRegex: "(\\.spec|.test)\\.(ts|tsx|js)$",
|
|
44
|
-
modulePaths: ["<rootDir>/dir/", "<rootDir>/node_modules/"],
|
|
45
|
-
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
46
9
|
testPathIgnorePatterns: ["/dist/"],
|
|
47
10
|
moduleNameMapper: {
|
|
48
11
|
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/../../__mocks__/fileMock.js",
|
|
49
12
|
"\\.(css|less|scss|sass)$": "@tinacms/scripts/__mocks__/styleMock.js"
|
|
50
13
|
}
|
|
51
14
|
};
|
|
52
|
-
var jest_runner_default =
|
|
53
|
-
|
|
54
|
-
|
|
15
|
+
var jest_runner_default = config;
|
|
16
|
+
export {
|
|
17
|
+
jest_runner_default as default
|
|
55
18
|
};
|
package/package.json
CHANGED
|
@@ -1,31 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/scripts",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0-ece366b-20260804150807",
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"files": [
|
|
6
7
|
"dist",
|
|
7
8
|
"bin/*",
|
|
8
|
-
"__mocks__/styleMock.js"
|
|
9
|
-
".env"
|
|
9
|
+
"__mocks__/styleMock.js"
|
|
10
10
|
],
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"bin": {
|
|
13
13
|
"tinacms-scripts": "./bin/tina-build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
"chalk": "^4.1.2",
|
|
16
|
+
"chalk": "^5.4.1",
|
|
18
17
|
"chokidar": "^3.6.0",
|
|
19
18
|
"commander": "^7.2.0",
|
|
20
|
-
"esbuild": "^0.
|
|
21
|
-
"fs-extra": "^11.
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
19
|
+
"esbuild": "^0.25.0",
|
|
20
|
+
"fs-extra": "^11.3.0",
|
|
21
|
+
"json-diff": "^1.0.6",
|
|
22
|
+
"tsup": "^8.3.6",
|
|
23
|
+
"typescript": "^5.7.3",
|
|
24
|
+
"vite": "^6.4.3"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/fs-extra": "^11.0.4",
|
|
28
|
+
"@types/json-diff": "^1.0.3",
|
|
29
|
+
"jest": "^30.1.3"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"url": "https://github.com/tinacms/tinacms.git",
|
|
33
|
+
"directory": "packages/@tinacms/scripts"
|
|
25
34
|
},
|
|
26
35
|
"scripts": {
|
|
27
36
|
"build:all": "bin/tina-build build:all",
|
|
28
37
|
"watch": "node bin/tina-build watch",
|
|
29
|
-
"build": "pnpm tsup src/jest-runner.ts src/
|
|
38
|
+
"build": "pnpm tsup src/jest-runner.ts src/index.ts --format esm"
|
|
30
39
|
}
|
|
31
40
|
}
|