@tinacms/scripts 0.0.0-00a8b82-20260824011213

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/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @tinacms/scripts
2
+
3
+ This package provides the `tinacms-scripts` bin with the following commands:
4
+
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
+
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.
@@ -0,0 +1,7 @@
1
+ /**
2
+
3
+ */
4
+
5
+ // __mocks__/styleMock.js
6
+
7
+ export default '';
package/bin/tina-build ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { BuildTina } from '../dist/index.js';
4
+ const tinaBuild = new BuildTina();
5
+ tinaBuild.init(process.argv);
@@ -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 ADDED
@@ -0,0 +1,471 @@
1
+ import {
2
+ __objRest,
3
+ __spreadValues
4
+ } from "./chunk-Q2LW34XU.js";
5
+
6
+ // src/index.ts
7
+ import * as fs from "fs";
8
+ import { exec } from "child_process";
9
+ import { createRequire } from "module";
10
+ import path from "path";
11
+ import chalk from "chalk";
12
+ import chokidar from "chokidar";
13
+ import commander from "commander";
14
+ import { build as esbuild } from "esbuild";
15
+ import fsExtra from "fs-extra";
16
+ import jsonDiff from "json-diff";
17
+ import { build } from "vite";
18
+
19
+ // src/utils.ts
20
+ function deepMerge(target, source) {
21
+ for (const key in source) {
22
+ if (!source.hasOwnProperty(key) || key === "__proto__" || key === "constructor")
23
+ continue;
24
+ if (source[key] instanceof Object && !Array.isArray(source[key]) && target.hasOwnProperty(key)) {
25
+ target[key] = deepMerge(target[key], source[key]);
26
+ } else if (Array.isArray(source[key]) && Array.isArray(target[key])) {
27
+ target[key] = [.../* @__PURE__ */ new Set([...target[key], ...source[key]])];
28
+ } else if (Array.isArray(source[key])) {
29
+ target[key] = [...source[key]];
30
+ } else {
31
+ target[key] = source[key];
32
+ }
33
+ }
34
+ return target;
35
+ }
36
+ async function sequential(items, callback) {
37
+ const accum = [];
38
+ if (!items) {
39
+ return [];
40
+ }
41
+ const reducePromises = async (previous, endpoint) => {
42
+ const prev = await previous;
43
+ if (prev) accum.push(prev);
44
+ return callback(endpoint, accum.length);
45
+ };
46
+ const result = await items.reduce(reducePromises, Promise.resolve());
47
+ if (result) {
48
+ accum.push(result);
49
+ }
50
+ return accum;
51
+ }
52
+
53
+ // src/index.ts
54
+ var { outputFileSync } = fsExtra;
55
+ var BuildTina = class {
56
+ constructor(name) {
57
+ this.program = new commander.Command(name);
58
+ }
59
+ registerCommands(commands, noHelp = false) {
60
+ for (const command of commands) {
61
+ const options = command.options || [];
62
+ let newCmd = this.program.command(command.command, { hidden: noHelp }).description(command.description).action((...args) => {
63
+ command.action(...args);
64
+ });
65
+ if (command.alias) {
66
+ newCmd = newCmd.alias(command.alias);
67
+ }
68
+ newCmd.on("--help", () => {
69
+ if (command.examples) console.log(`
70
+ Examples:
71
+ ${command.examples}`);
72
+ if (command.subCommands) {
73
+ console.log("\nCommands:");
74
+ const optionTag = " [options]";
75
+ for (const subcommand of command.subCommands) {
76
+ const commandStr = `${subcommand.command}${options.length ? optionTag : ""}`;
77
+ const padLength = Math.max(
78
+ ...command.subCommands.map((sub) => sub.command.length)
79
+ ) + optionTag.length;
80
+ console.log(
81
+ `${commandStr.padEnd(padLength)} ${subcommand.description}`
82
+ );
83
+ }
84
+ }
85
+ console.log("");
86
+ });
87
+ for (const option of options) {
88
+ newCmd.option(option.name, option.description);
89
+ }
90
+ if (command.subCommands) this.registerCommands(command.subCommands, true);
91
+ }
92
+ }
93
+ async run(args) {
94
+ var _a;
95
+ if (args.dir) process.chdir(args.dir);
96
+ let packageJson = null;
97
+ try {
98
+ const packageJsonContent = fs.readFileSync(
99
+ path.join(process.cwd(), "package.json")
100
+ );
101
+ packageJson = JSON.parse(packageJsonContent.toString());
102
+ } catch (err) {
103
+ const error = err;
104
+ console.error(`Failed to parse package.json: ${error.message}`);
105
+ process.exit(1);
106
+ }
107
+ if (["@tinacms/scripts", "@tinacms/webpack-helpers"].includes(
108
+ packageJson.name
109
+ )) {
110
+ console.info(`Skipping ${packageJson.name}`);
111
+ return;
112
+ }
113
+ const successMessage = `${chalk.blue(`${packageJson.name}`)} built in`;
114
+ console.time(successMessage);
115
+ const entries = ((_a = packageJson.buildConfig) == null ? void 0 : _a.entryPoints.map(
116
+ (ep) => {
117
+ if (typeof ep === "string") {
118
+ return { name: ep, target: "browser" };
119
+ }
120
+ return ep;
121
+ }
122
+ )) || [{ name: "src/index.ts", target: "browser" }];
123
+ try {
124
+ await sequential(entries, async (entry) => {
125
+ return this.buildPackage(entry, packageJson);
126
+ });
127
+ if (args.dir) console.timeEnd(successMessage);
128
+ } catch (err) {
129
+ const error = err;
130
+ console.error(`Failed to build ${packageJson.name}: ${error.message}`);
131
+ process.exit(1);
132
+ }
133
+ }
134
+ watch() {
135
+ try {
136
+ exec("pnpm list -r --json", (error, stdout) => {
137
+ if (error) {
138
+ throw error;
139
+ }
140
+ const json = JSON.parse(stdout);
141
+ const watchPaths = [];
142
+ for (const pkg of json) {
143
+ const pkgPath = "packages";
144
+ if (pkg.path.includes(pkgPath)) watchPaths.push(pkg.path);
145
+ }
146
+ chokidar.watch(
147
+ watchPaths.map((p) => path.join(p, "src", "**/*")),
148
+ { ignored: ["**/spec/**/*", "node_modules"] }
149
+ ).on("change", async (path2) => {
150
+ const changedPackagePath = watchPaths.find(
151
+ (p) => path2.startsWith(p)
152
+ );
153
+ await this.run({ dir: changedPackagePath });
154
+ });
155
+ });
156
+ } catch (err) {
157
+ const error = err;
158
+ console.error(`Failed to exec watch command: ${error.message}`);
159
+ process.exit(1);
160
+ }
161
+ }
162
+ diffTinaLock() {
163
+ if (!fs.existsSync(`tina/tina-lock.json`)) {
164
+ console.error(
165
+ "No Tina lock found. Please run this command from the root of a Tina project \u274C"
166
+ );
167
+ process.exit(1);
168
+ }
169
+ let tinaLock = null;
170
+ try {
171
+ const tinaLockContent = fs.readFileSync(
172
+ "tina/tina-lock.json"
173
+ );
174
+ tinaLock = JSON.parse(tinaLockContent.toString());
175
+ if (!tinaLock.schema) {
176
+ throw new Error("No schema found in the Tina lock \u274C");
177
+ }
178
+ } catch (err) {
179
+ const error = err;
180
+ console.error(`Failed to parse tina/tina-lock.json: ${error.message}`);
181
+ process.exit(1);
182
+ }
183
+ try {
184
+ exec(
185
+ "pnpm exec tinacms dev --no-server",
186
+ { cwd: process.cwd() },
187
+ (error, stdout, stderr) => {
188
+ if (error) {
189
+ throw error;
190
+ }
191
+ if (stderr) {
192
+ throw new Error(stderr);
193
+ }
194
+ if (stdout) {
195
+ console.log(
196
+ stdout.split("\n").map((line) => `> ${line}`).join("\n")
197
+ );
198
+ }
199
+ let newTinaLock = null;
200
+ try {
201
+ const newTinaLockContent = fs.readFileSync(
202
+ "tina/tina-lock.json"
203
+ );
204
+ newTinaLock = JSON.parse(newTinaLockContent.toString());
205
+ if (!newTinaLock.schema) {
206
+ throw new Error("No schema found in the new Tina lock \u274C");
207
+ }
208
+ } catch (err) {
209
+ const error2 = err;
210
+ console.error(
211
+ `Failed to parse tina/tina-lock.json: ${error2.message}`
212
+ );
213
+ throw error2;
214
+ }
215
+ const _a = tinaLock.schema, { version } = _a, schema = __objRest(_a, ["version"]);
216
+ const _b = newTinaLock.schema, { version: newVersion } = _b, newSchema = __objRest(_b, ["version"]);
217
+ const schemaDiff = jsonDiff.diffString(schema, newSchema);
218
+ if (schemaDiff) {
219
+ console.error("Unexpected change(s) to Tina schema \u274C");
220
+ console.error(schemaDiff);
221
+ throw new Error("Unexpected change(s) to Tina schema \u274C");
222
+ }
223
+ const graphqlDiff = jsonDiff.diffString(
224
+ tinaLock.graphql,
225
+ newTinaLock.graphql
226
+ );
227
+ if (graphqlDiff) {
228
+ console.error("Unexpected change(s) to Tina graphql schema \u274C");
229
+ console.error(graphqlDiff);
230
+ throw new Error("Unexpected change(s) to Tina grahpql schema \u274C");
231
+ }
232
+ console.log("No changes found in Tina lock \u2705");
233
+ }
234
+ );
235
+ } catch (err) {
236
+ const error = err;
237
+ console.error(`Failed to start dev server: ${error.message}`);
238
+ process.exit(1);
239
+ }
240
+ }
241
+ init(args) {
242
+ this.registerCommands([
243
+ {
244
+ command: "build",
245
+ description: "Build",
246
+ options: [
247
+ {
248
+ name: "--watch",
249
+ description: "Watch for file changes and rebuild"
250
+ }
251
+ ],
252
+ action: (options) => this.run(options)
253
+ },
254
+ {
255
+ command: "watch",
256
+ description: "Watch",
257
+ action: () => this.watch()
258
+ },
259
+ {
260
+ command: "diff-tina-lock",
261
+ description: "Compare the current schema for a tina project with newly generated schema",
262
+ action: () => this.diffTinaLock()
263
+ }
264
+ ]);
265
+ this.program.usage("command [options]");
266
+ this.program.on("command:*", function() {
267
+ console.error(
268
+ `Invalid command: ${args.join(" ")}
269
+ See --help for a list of available commands.`
270
+ );
271
+ process.exit(1);
272
+ });
273
+ this.program.on("--help", function() {
274
+ console.log(
275
+ 'You can get help on any command with "-h" or "--help".\ne.g: "forestry types:gen --help"'
276
+ );
277
+ });
278
+ if (!process.argv.slice(2).length) {
279
+ this.program.help();
280
+ }
281
+ this.program.parse(args);
282
+ }
283
+ getOutputPaths(entry) {
284
+ const { dir, name } = path.parse(entry);
285
+ const outdir = dir.replace("src", "dist");
286
+ const outfile = name;
287
+ const relativeOutfile = path.join(
288
+ outdir.split("/").map(() => "..").join("/"),
289
+ dir,
290
+ name
291
+ );
292
+ return { outdir, outfile, relativeOutfile };
293
+ }
294
+ async buildPackage(entryPoint, packageJSON) {
295
+ const entry = entryPoint.name;
296
+ const target = entryPoint.target;
297
+ const extension = path.extname(entry);
298
+ const deps = packageJSON.dependencies;
299
+ const peerDeps = packageJSON.peerDependencies;
300
+ const external = Object.keys(__spreadValues(__spreadValues({}, deps), peerDeps));
301
+ const outInfo = this.getOutputPaths(entry);
302
+ const globals = {};
303
+ if (["@tinacms/app"].includes(packageJSON.name)) {
304
+ console.log("skipping @tinacms/app");
305
+ return;
306
+ }
307
+ if (["@tinacms/web-components"].includes(packageJSON.name)) {
308
+ await esbuild({
309
+ entryPoints: [path.join(process.cwd(), entry)],
310
+ bundle: true,
311
+ platform: "browser",
312
+ target: "esnext",
313
+ format: "esm",
314
+ outfile: path.join(process.cwd(), "dist", `${outInfo.outfile}.js`)
315
+ });
316
+ return true;
317
+ }
318
+ external.forEach((ext) => globals[ext] = "NOOP");
319
+ const isExternal = (id) => external.some((dep) => id === dep || id.startsWith(`${dep}/`));
320
+ if (target === "node") {
321
+ if (["@tinacms/graphql", "@tinacms/datalayer"].includes(packageJSON.name)) {
322
+ await esbuild({
323
+ entryPoints: [path.join(process.cwd(), entry)],
324
+ bundle: true,
325
+ platform: "node",
326
+ target: "esnext",
327
+ format: "esm",
328
+ outfile: path.join(
329
+ process.cwd(),
330
+ "dist",
331
+ `${outInfo.outfile ? outInfo.outfile : "index"}.js`
332
+ ),
333
+ external: external.filter((item) => {
334
+ const entryPoint2 = packageJSON.buildConfig.entryPoints[0];
335
+ if (typeof entryPoint2 === "string") return false;
336
+ return !entryPoint2.bundle.includes(item);
337
+ })
338
+ });
339
+ await esbuild({
340
+ entryPoints: [path.join(process.cwd(), entry)],
341
+ bundle: true,
342
+ platform: "node",
343
+ target: "esnext",
344
+ format: "esm",
345
+ outfile: path.join(
346
+ process.cwd(),
347
+ "dist",
348
+ `${outInfo.outfile ? outInfo.outfile : "index"}.js`
349
+ ),
350
+ external
351
+ });
352
+ } else if (["@tinacms/mdx"].includes(packageJSON.name)) {
353
+ const peerDeps2 = packageJSON.peerDependencies;
354
+ const acornManifest = createRequire(
355
+ path.join(process.cwd(), "package.json")
356
+ ).resolve("acorn/package.json");
357
+ const alias = {
358
+ acorn: path.join(
359
+ path.dirname(acornManifest),
360
+ JSON.parse(fs.readFileSync(acornManifest, "utf8")).module
361
+ )
362
+ };
363
+ await esbuild({
364
+ entryPoints: [path.join(process.cwd(), entry)],
365
+ bundle: true,
366
+ platform: "node",
367
+ target: "esnext",
368
+ format: "esm",
369
+ outfile: path.join(process.cwd(), "dist", "index.js"),
370
+ external: Object.keys(__spreadValues({}, peerDeps2)),
371
+ alias
372
+ });
373
+ await esbuild({
374
+ entryPoints: [path.join(process.cwd(), entry)],
375
+ bundle: true,
376
+ platform: "browser",
377
+ target: "esnext",
378
+ format: "esm",
379
+ outfile: path.join(process.cwd(), "dist", "index.browser.js"),
380
+ // Bundle dependencies, the remark ecosystem only publishes ES modules
381
+ // and includes "development" export maps which actually throw errors during
382
+ // development, which we don't want to expose our users to.
383
+ external: Object.keys(__spreadValues({}, peerDeps2)),
384
+ alias
385
+ });
386
+ } else {
387
+ await esbuild({
388
+ entryPoints: [path.join(process.cwd(), entry)],
389
+ bundle: true,
390
+ platform: "node",
391
+ target: "esnext",
392
+ format: "esm",
393
+ outfile: path.join(process.cwd(), "dist", `${outInfo.outfile}.js`),
394
+ external
395
+ });
396
+ }
397
+ fs.writeFileSync(
398
+ path.join(
399
+ process.cwd(),
400
+ "dist",
401
+ entry.replace("src/", "").replace(extension, ".d.ts")
402
+ ),
403
+ `export * from "../${entry.replace(extension, "")}"`
404
+ );
405
+ return true;
406
+ }
407
+ const defaultBuildConfig = {
408
+ resolve: {
409
+ alias: {
410
+ "@toolkit": path.resolve(process.cwd(), "src/toolkit"),
411
+ "@tinacms/toolkit": path.resolve(
412
+ process.cwd(),
413
+ "src/toolkit/index.ts"
414
+ ),
415
+ "@utils": path.resolve(process.cwd(), "src/utils")
416
+ }
417
+ },
418
+ build: {
419
+ minify: false,
420
+ assetsInlineLimit: 0,
421
+ lib: {
422
+ entry: path.resolve(process.cwd(), entry),
423
+ name: packageJSON.name,
424
+ formats: ["es"],
425
+ fileName: () => `${outInfo.outfile}.js`
426
+ },
427
+ outDir: outInfo.outdir,
428
+ emptyOutDir: false,
429
+ // We build multiple files in to the dir.
430
+ sourcemap: false,
431
+ rollupOptions: {
432
+ onwarn(warning, warn) {
433
+ if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
434
+ return;
435
+ }
436
+ warn(warning);
437
+ },
438
+ plugins: [],
439
+ /**
440
+ * For some reason Rollup thinks it needs a global, though
441
+ * I'm pretty sure it doesn't, since everything works
442
+ *
443
+ * By setting a global for each external dep we're silencing these warnings
444
+ * No name was provided for external module in output.globals
445
+ *
446
+ * They don't occur for es builds, only UMD and I can't quite find
447
+ * an authoritative response on wny they're needed or how they're
448
+ * used in the UMD context.
449
+ *
450
+ * https://github.com/rollup/rollup/issues/1514#issuecomment-321877507
451
+ * https://github.com/rollup/rollup/issues/1169#issuecomment-268815735
452
+ */
453
+ output: {
454
+ globals
455
+ },
456
+ external: isExternal
457
+ }
458
+ }
459
+ };
460
+ const buildConfig = packageJSON.buildConfig ? deepMerge(defaultBuildConfig, packageJSON.buildConfig) : defaultBuildConfig;
461
+ await build(__spreadValues({}, buildConfig));
462
+ outputFileSync(
463
+ path.join(outInfo.outdir, `${outInfo.outfile}.d.ts`),
464
+ `export * from "${outInfo.relativeOutfile}"`
465
+ );
466
+ return true;
467
+ }
468
+ };
469
+ export {
470
+ BuildTina
471
+ };
@@ -0,0 +1,18 @@
1
+ import "./chunk-Q2LW34XU.js";
2
+
3
+ // src/jest-runner.ts
4
+ var config = {
5
+ verbose: true,
6
+ transform: {
7
+ "^.+\\.[tj]sx?$": "babel-jest"
8
+ },
9
+ testPathIgnorePatterns: ["/dist/"],
10
+ moduleNameMapper: {
11
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/../../__mocks__/fileMock.js",
12
+ "\\.(css|less|scss|sass)$": "@tinacms/scripts/__mocks__/styleMock.js"
13
+ }
14
+ };
15
+ var jest_runner_default = config;
16
+ export {
17
+ jest_runner_default as default
18
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@tinacms/scripts",
3
+ "type": "module",
4
+ "version": "0.0.0-00a8b82-20260824011213",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist",
8
+ "bin/*",
9
+ "__mocks__/styleMock.js"
10
+ ],
11
+ "license": "Apache-2.0",
12
+ "bin": {
13
+ "tinacms-scripts": "./bin/tina-build"
14
+ },
15
+ "dependencies": {
16
+ "chalk": "^5.4.1",
17
+ "chokidar": "^3.6.0",
18
+ "commander": "^7.2.0",
19
+ "esbuild": "^0.28.1",
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"
34
+ },
35
+ "scripts": {
36
+ "build:all": "bin/tina-build build:all",
37
+ "watch": "node bin/tina-build watch",
38
+ "build": "pnpm tsup src/jest-runner.ts src/index.ts --format esm"
39
+ }
40
+ }