@tinacms/scripts 1.4.0 → 1.4.2

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/bin/tina-build CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { BuildTina} = require('../dist/index.js')
4
- const tinaBuild = new BuildTina()
5
- tinaBuild.init(process.argv)
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 CHANGED
@@ -1,73 +1,19 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
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 __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
- };
33
- var __export = (target, all) => {
34
- for (var name in all)
35
- __defProp(target, name, { get: all[name], enumerable: true });
36
- };
37
- var __copyProps = (to, from, except, desc) => {
38
- if (from && typeof from === "object" || typeof from === "function") {
39
- for (let key of __getOwnPropNames(from))
40
- if (!__hasOwnProp.call(to, key) && key !== except)
41
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
- }
43
- return to;
44
- };
45
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
46
- // If the importer is in node compatibility mode or this is not an ESM
47
- // file that has been converted to a CommonJS file using a Babel-
48
- // compatible transform (i.e. "__esModule" has not been set), then set
49
- // "default" to the CommonJS "module.exports" for node compatibility.
50
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
51
- mod
52
- ));
53
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ import {
2
+ __objRest,
3
+ __spreadValues
4
+ } from "./chunk-Q2LW34XU.js";
54
5
 
55
6
  // src/index.ts
56
- var index_exports = {};
57
- __export(index_exports, {
58
- BuildTina: () => BuildTina
59
- });
60
- module.exports = __toCommonJS(index_exports);
61
- var fs = __toESM(require("fs"));
62
- var import_node_child_process = require("child_process");
63
- var import_node_path = __toESM(require("path"));
64
- var import_chalk = __toESM(require("chalk"));
65
- var import_chokidar = __toESM(require("chokidar"));
66
- var import_commander = __toESM(require("commander"));
67
- var import_esbuild = require("esbuild");
68
- var import_fs_extra = require("fs-extra");
69
- var import_json_diff = __toESM(require("json-diff"));
70
- var import_vite = require("vite");
7
+ import * as fs from "fs";
8
+ import { exec } from "node:child_process";
9
+ import path from "node: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";
71
17
 
72
18
  // src/utils.ts
73
19
  function deepMerge(target, source) {
@@ -104,9 +50,10 @@ async function sequential(items, callback) {
104
50
  }
105
51
 
106
52
  // src/index.ts
53
+ var { outputFileSync } = fsExtra;
107
54
  var BuildTina = class {
108
55
  constructor(name) {
109
- this.program = new import_commander.default.Command(name);
56
+ this.program = new commander.Command(name);
110
57
  }
111
58
  registerCommands(commands, noHelp = false) {
112
59
  for (const command of commands) {
@@ -148,7 +95,7 @@ Examples:
148
95
  let packageJson = null;
149
96
  try {
150
97
  const packageJsonContent = fs.readFileSync(
151
- import_node_path.default.join(process.cwd(), "package.json")
98
+ path.join(process.cwd(), "package.json")
152
99
  );
153
100
  packageJson = JSON.parse(packageJsonContent.toString());
154
101
  } catch (err) {
@@ -162,7 +109,7 @@ Examples:
162
109
  console.info(`Skipping ${packageJson.name}`);
163
110
  return;
164
111
  }
165
- const successMessage = `${import_chalk.default.blue(`${packageJson.name}`)} built in`;
112
+ const successMessage = `${chalk.blue(`${packageJson.name}`)} built in`;
166
113
  console.time(successMessage);
167
114
  const entries = ((_a = packageJson.buildConfig) == null ? void 0 : _a.entryPoints.map(
168
115
  (ep) => {
@@ -185,7 +132,7 @@ Examples:
185
132
  }
186
133
  watch() {
187
134
  try {
188
- (0, import_node_child_process.exec)("pnpm list -r --json", (error, stdout) => {
135
+ exec("pnpm list -r --json", (error, stdout) => {
189
136
  if (error) {
190
137
  throw error;
191
138
  }
@@ -195,8 +142,8 @@ Examples:
195
142
  const pkgPath = "packages";
196
143
  if (pkg.path.includes(pkgPath)) watchPaths.push(pkg.path);
197
144
  }
198
- import_chokidar.default.watch(
199
- watchPaths.map((p) => import_node_path.default.join(p, "src", "**/*")),
145
+ chokidar.watch(
146
+ watchPaths.map((p) => path.join(p, "src", "**/*")),
200
147
  { ignored: ["**/spec/**/*", "node_modules"] }
201
148
  ).on("change", async (path2) => {
202
149
  const changedPackagePath = watchPaths.find(
@@ -233,7 +180,7 @@ Examples:
233
180
  process.exit(1);
234
181
  }
235
182
  try {
236
- (0, import_node_child_process.exec)(
183
+ exec(
237
184
  "pnpm exec tinacms dev --no-server",
238
185
  { cwd: process.cwd() },
239
186
  (error, stdout, stderr) => {
@@ -266,13 +213,13 @@ Examples:
266
213
  }
267
214
  const _a = tinaLock.schema, { version } = _a, schema = __objRest(_a, ["version"]);
268
215
  const _b = newTinaLock.schema, { version: newVersion } = _b, newSchema = __objRest(_b, ["version"]);
269
- const schemaDiff = import_json_diff.default.diffString(schema, newSchema);
216
+ const schemaDiff = jsonDiff.diffString(schema, newSchema);
270
217
  if (schemaDiff) {
271
218
  console.error("Unexpected change(s) to Tina schema \u274C");
272
219
  console.error(schemaDiff);
273
220
  throw new Error("Unexpected change(s) to Tina schema \u274C");
274
221
  }
275
- const graphqlDiff = import_json_diff.default.diffString(
222
+ const graphqlDiff = jsonDiff.diffString(
276
223
  tinaLock.graphql,
277
224
  newTinaLock.graphql
278
225
  );
@@ -333,10 +280,10 @@ See --help for a list of available commands.`
333
280
  this.program.parse(args);
334
281
  }
335
282
  getOutputPaths(entry) {
336
- const { dir, name } = import_node_path.default.parse(entry);
283
+ const { dir, name } = path.parse(entry);
337
284
  const outdir = dir.replace("src", "dist");
338
285
  const outfile = name;
339
- const relativeOutfile = import_node_path.default.join(
286
+ const relativeOutfile = path.join(
340
287
  outdir.split("/").map(() => "..").join("/"),
341
288
  dir,
342
289
  name
@@ -346,7 +293,7 @@ See --help for a list of available commands.`
346
293
  async buildPackage(entryPoint, packageJSON) {
347
294
  const entry = entryPoint.name;
348
295
  const target = entryPoint.target;
349
- const extension = import_node_path.default.extname(entry);
296
+ const extension = path.extname(entry);
350
297
  const deps = packageJSON.dependencies;
351
298
  const peerDeps = packageJSON.peerDependencies;
352
299
  const external = Object.keys(__spreadValues(__spreadValues({}, deps), peerDeps));
@@ -359,12 +306,13 @@ See --help for a list of available commands.`
359
306
  external.forEach((ext) => globals[ext] = "NOOP");
360
307
  if (target === "node") {
361
308
  if (["@tinacms/graphql", "@tinacms/datalayer"].includes(packageJSON.name)) {
362
- await (0, import_esbuild.build)({
363
- entryPoints: [import_node_path.default.join(process.cwd(), entry)],
309
+ await esbuild({
310
+ entryPoints: [path.join(process.cwd(), entry)],
364
311
  bundle: true,
365
312
  platform: "node",
366
- target: "node20",
367
- outfile: import_node_path.default.join(
313
+ target: "esnext",
314
+ format: "esm",
315
+ outfile: path.join(
368
316
  process.cwd(),
369
317
  "dist",
370
318
  `${outInfo.outfile ? outInfo.outfile : "index"}.js`
@@ -375,66 +323,55 @@ See --help for a list of available commands.`
375
323
  return !entryPoint2.bundle.includes(item);
376
324
  })
377
325
  });
378
- await (0, import_esbuild.build)({
379
- entryPoints: [import_node_path.default.join(process.cwd(), entry)],
326
+ await esbuild({
327
+ entryPoints: [path.join(process.cwd(), entry)],
380
328
  bundle: true,
381
329
  platform: "node",
382
- target: "es2020",
330
+ target: "esnext",
383
331
  format: "esm",
384
- outfile: import_node_path.default.join(
332
+ outfile: path.join(
385
333
  process.cwd(),
386
334
  "dist",
387
- `${outInfo.outfile ? outInfo.outfile : "index"}.mjs`
335
+ `${outInfo.outfile ? outInfo.outfile : "index"}.js`
388
336
  ),
389
337
  external
390
338
  });
391
339
  } else if (["@tinacms/mdx"].includes(packageJSON.name)) {
392
340
  const peerDeps2 = packageJSON.peerDependencies;
393
- await (0, import_esbuild.build)({
394
- entryPoints: [import_node_path.default.join(process.cwd(), entry)],
341
+ await esbuild({
342
+ entryPoints: [path.join(process.cwd(), entry)],
395
343
  bundle: true,
396
344
  platform: "node",
397
- target: "node20",
398
- format: "cjs",
399
- outfile: import_node_path.default.join(process.cwd(), "dist", "index.js"),
400
- external: Object.keys(__spreadValues({}, peerDeps2))
401
- });
402
- await (0, import_esbuild.build)({
403
- entryPoints: [import_node_path.default.join(process.cwd(), entry)],
404
- bundle: true,
405
- platform: "node",
406
- target: "es2020",
345
+ target: "esnext",
407
346
  format: "esm",
408
- outfile: import_node_path.default.join(process.cwd(), "dist", "index.mjs"),
409
- // Bundle dependencies, the remark ecosystem only publishes ES modules
410
- // and includes "development" export maps which actually throw errors during
411
- // development, which we don't want to expose our users to.
347
+ outfile: path.join(process.cwd(), "dist", "index.js"),
412
348
  external: Object.keys(__spreadValues({}, peerDeps2))
413
349
  });
414
- await (0, import_esbuild.build)({
415
- entryPoints: [import_node_path.default.join(process.cwd(), entry)],
350
+ await esbuild({
351
+ entryPoints: [path.join(process.cwd(), entry)],
416
352
  bundle: true,
417
353
  platform: "browser",
418
- target: "es2020",
354
+ target: "esnext",
419
355
  format: "esm",
420
- outfile: import_node_path.default.join(process.cwd(), "dist", "index.browser.mjs"),
356
+ outfile: path.join(process.cwd(), "dist", "index.browser.js"),
421
357
  // Bundle dependencies, the remark ecosystem only publishes ES modules
422
358
  // and includes "development" export maps which actually throw errors during
423
359
  // development, which we don't want to expose our users to.
424
360
  external: Object.keys(__spreadValues({}, peerDeps2))
425
361
  });
426
362
  } else {
427
- await (0, import_esbuild.build)({
428
- entryPoints: [import_node_path.default.join(process.cwd(), entry)],
363
+ await esbuild({
364
+ entryPoints: [path.join(process.cwd(), entry)],
429
365
  bundle: true,
430
366
  platform: "node",
431
- target: "node20",
432
- outfile: import_node_path.default.join(process.cwd(), "dist", `${outInfo.outfile}.js`),
367
+ target: "esnext",
368
+ format: "esm",
369
+ outfile: path.join(process.cwd(), "dist", `${outInfo.outfile}.js`),
433
370
  external
434
371
  });
435
372
  }
436
373
  fs.writeFileSync(
437
- import_node_path.default.join(
374
+ path.join(
438
375
  process.cwd(),
439
376
  "dist",
440
377
  entry.replace("src/", "").replace(extension, ".d.ts")
@@ -446,8 +383,8 @@ See --help for a list of available commands.`
446
383
  const defaultBuildConfig = {
447
384
  resolve: {
448
385
  alias: {
449
- "@toolkit": import_node_path.default.resolve(process.cwd(), "src/toolkit"),
450
- "@tinacms/toolkit": import_node_path.default.resolve(
386
+ "@toolkit": path.resolve(process.cwd(), "src/toolkit"),
387
+ "@tinacms/toolkit": path.resolve(
451
388
  process.cwd(),
452
389
  "src/toolkit/index.ts"
453
390
  )
@@ -457,11 +394,10 @@ See --help for a list of available commands.`
457
394
  minify: false,
458
395
  assetsInlineLimit: 0,
459
396
  lib: {
460
- entry: import_node_path.default.resolve(process.cwd(), entry),
397
+ entry: path.resolve(process.cwd(), entry),
461
398
  name: packageJSON.name,
462
- fileName: (format) => {
463
- return format === "umd" ? `${outInfo.outfile}.js` : `${outInfo.outfile}.mjs`;
464
- }
399
+ formats: ["es"],
400
+ fileName: () => `${outInfo.outfile}.js`
465
401
  },
466
402
  outDir: outInfo.outdir,
467
403
  emptyOutDir: false,
@@ -480,7 +416,7 @@ See --help for a list of available commands.`
480
416
  * I'm pretty sure it doesn't, since everything works
481
417
  *
482
418
  * By setting a global for each external dep we're silencing these warnings
483
- * No name was provided for external module 'react-beautiful-dnd' in output.globals – guessing 'reactBeautifulDnd'
419
+ * No name was provided for external module in output.globals
484
420
  *
485
421
  * They don't occur for es builds, only UMD and I can't quite find
486
422
  * an authoritative response on wny they're needed or how they're
@@ -497,15 +433,14 @@ See --help for a list of available commands.`
497
433
  }
498
434
  };
499
435
  const buildConfig = packageJSON.buildConfig ? deepMerge(defaultBuildConfig, packageJSON.buildConfig) : defaultBuildConfig;
500
- await (0, import_vite.build)(__spreadValues({}, buildConfig));
501
- (0, import_fs_extra.outputFileSync)(
502
- import_node_path.default.join(outInfo.outdir, `${outInfo.outfile}.d.ts`),
436
+ await build(__spreadValues({}, buildConfig));
437
+ outputFileSync(
438
+ path.join(outInfo.outdir, `${outInfo.outfile}.d.ts`),
503
439
  `export * from "${outInfo.relativeOutfile}"`
504
440
  );
505
441
  return true;
506
442
  }
507
443
  };
508
- // Annotate the CommonJS export names for ESM import in node:
509
- 0 && (module.exports = {
444
+ export {
510
445
  BuildTina
511
- });
446
+ };
@@ -1,55 +1,18 @@
1
- var __create = Object.create;
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
- ".(ts|tsx)": "@tinacms/scripts/dist/jest-runner.js",
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
- process: import_jest_plugin.default.process,
54
- config
15
+ var jest_runner_default = config;
16
+ export {
17
+ jest_runner_default as default
55
18
  };
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/scripts",
3
- "version": "1.4.0",
3
+ "type": "module",
4
+ "version": "1.4.2",
4
5
  "main": "dist/index.js",
5
6
  "files": [
6
7
  "dist",
@@ -14,7 +15,7 @@
14
15
  },
15
16
  "dependencies": {
16
17
  "@sucrase/jest-plugin": "^3.0.0",
17
- "chalk": "^4.1.2",
18
+ "chalk": "^5.4.1",
18
19
  "chokidar": "^3.6.0",
19
20
  "commander": "^7.2.0",
20
21
  "esbuild": "^0.24.2",
@@ -26,11 +27,12 @@
26
27
  },
27
28
  "devDependencies": {
28
29
  "@types/fs-extra": "^11.0.4",
29
- "@types/json-diff": "^1.0.3"
30
+ "@types/json-diff": "^1.0.3",
31
+ "jest": "^30.1.3"
30
32
  },
31
33
  "scripts": {
32
34
  "build:all": "bin/tina-build build:all",
33
35
  "watch": "node bin/tina-build watch",
34
- "build": "pnpm tsup src/jest-runner.ts src/css-transform.ts src/index.ts --format cjs"
36
+ "build": "pnpm tsup src/jest-runner.ts src/css-transform.ts src/index.ts --format esm"
35
37
  }
36
38
  }