@storm-software/workspace-tools 1.24.2 → 1.26.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.25.0](https://github.com/storm-software/storm-ops/compare/workspace-tools-v1.24.2...workspace-tools-v1.25.0) (2023-12-11)
2
+
3
+
4
+ ### Features
5
+
6
+ * **workspace-tools:** Added the `generatePackageJson` option to tsup build ([c067c9b](https://github.com/storm-software/storm-ops/commit/c067c9baaf639b8e508e5fdc2789da2f8378c4b8))
7
+
8
+ ## [1.24.2](https://github.com/storm-software/storm-ops/compare/workspace-tools-v1.24.1...workspace-tools-v1.24.2) (2023-12-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **workspace-tools:** Update tsup build to not include `src` folder by default ([d400c33](https://github.com/storm-software/storm-ops/commit/d400c338e29ddfbe4c3288f1015db972849c7181))
14
+
1
15
  ## [1.24.1](https://github.com/storm-software/storm-ops/compare/workspace-tools-v1.24.0...workspace-tools-v1.24.1) (2023-12-11)
2
16
 
3
17
 
package/index.js CHANGED
@@ -117184,6 +117184,7 @@ function modernConfig({
117184
117184
  splitting,
117185
117185
  treeshake,
117186
117186
  debug = false,
117187
+ shims = true,
117187
117188
  external,
117188
117189
  banner = {},
117189
117190
  platform = "neutral",
@@ -117194,6 +117195,7 @@ function modernConfig({
117194
117195
  define: define2,
117195
117196
  env: env2,
117196
117197
  plugins,
117198
+ generatePackageJson,
117197
117199
  dtsTsConfig
117198
117200
  }) {
117199
117201
  let outputPath = (0, import_path3.join)(outDir, "dist", "modern");
@@ -117212,6 +117214,7 @@ function modernConfig({
117212
117214
  ] : ["esnext", "node18"],
117213
117215
  tsconfig,
117214
117216
  splitting,
117217
+ generatePackageJson,
117215
117218
  treeshake: treeshake ? {
117216
117219
  preset: "recommended"
117217
117220
  } : false,
@@ -117220,7 +117223,7 @@ function modernConfig({
117220
117223
  outDir: outputPath,
117221
117224
  silent: !verbose,
117222
117225
  metafile: true,
117223
- shims: true,
117226
+ shims,
117224
117227
  external,
117225
117228
  platform,
117226
117229
  banner,
@@ -117267,9 +117270,11 @@ function legacyConfig({
117267
117270
  banner = {},
117268
117271
  platform = "neutral",
117269
117272
  verbose = false,
117273
+ shims = true,
117270
117274
  define: define2,
117271
117275
  env: env2,
117272
117276
  plugins,
117277
+ generatePackageJson,
117273
117278
  dtsTsConfig
117274
117279
  }) {
117275
117280
  let outputPath = (0, import_path3.join)(outDir, "dist", "legacy");
@@ -117280,6 +117285,7 @@ function legacyConfig({
117280
117285
  target: ["es2022", "node18"],
117281
117286
  tsconfig,
117282
117287
  splitting,
117288
+ generatePackageJson,
117283
117289
  treeshake: treeshake ? {
117284
117290
  preset: "recommended"
117285
117291
  } : false,
@@ -117288,7 +117294,7 @@ function legacyConfig({
117288
117294
  outDir: outputPath,
117289
117295
  silent: !verbose,
117290
117296
  metafile: true,
117291
- shims: true,
117297
+ shims,
117292
117298
  external,
117293
117299
  platform,
117294
117300
  banner,
@@ -117337,9 +117343,11 @@ function workerConfig({
117337
117343
  apiReport = true,
117338
117344
  docModel = true,
117339
117345
  tsdocMetadata = true,
117346
+ shims = false,
117340
117347
  define: define2,
117341
117348
  env: env2,
117342
117349
  plugins,
117350
+ generatePackageJson,
117343
117351
  dtsTsConfig
117344
117352
  }) {
117345
117353
  let outputPath = (0, import_path3.join)(outDir, "dist");
@@ -117351,6 +117359,7 @@ function workerConfig({
117351
117359
  bundle: true,
117352
117360
  tsconfig,
117353
117361
  splitting,
117362
+ generatePackageJson,
117354
117363
  treeshake: treeshake ? {
117355
117364
  preset: "recommended"
117356
117365
  } : false,
@@ -117359,7 +117368,7 @@ function workerConfig({
117359
117368
  outDir: outputPath,
117360
117369
  silent: !verbose,
117361
117370
  metafile: true,
117362
- shims: false,
117371
+ shims,
117363
117372
  external,
117364
117373
  platform: "browser",
117365
117374
  banner,
@@ -117489,6 +117498,13 @@ ${Object.keys(options).map(
117489
117498
  glob: "LICENSE",
117490
117499
  output: "."
117491
117500
  });
117501
+ if (options.generatePackageJson === false) {
117502
+ assets.push({
117503
+ input: projectRoot,
117504
+ glob: "**/package.json",
117505
+ output: "."
117506
+ });
117507
+ }
117492
117508
  if (options.includeSrc !== false) {
117493
117509
  assets.push({
117494
117510
  input: sourceRoot,
@@ -117554,84 +117570,6 @@ ${externalDependencies.map((dep) => {
117554
117570
  }
117555
117571
  }
117556
117572
  }
117557
- const projectGraph = (0, import_devkit.readCachedProjectGraph)();
117558
- const pathToPackageJson = (0, import_path4.join)(context.root, projectRoot, "package.json");
117559
- const packageJson = (0, import_fileutils.fileExists)(pathToPackageJson) ? (0, import_devkit.readJsonFile)(pathToPackageJson) : { name: context.projectName, version: "0.0.1" };
117560
- delete packageJson.dependencies;
117561
- externalDependencies.forEach((entry) => {
117562
- const packageConfig = entry.node.data;
117563
- if (packageConfig?.packageName && (!!(projectGraph.externalNodes[entry.node.name]?.type === "npm") || !!projectGraph.nodes[entry.node.name])) {
117564
- const { packageName, version } = packageConfig;
117565
- if (workspacePackageJson.dependencies?.[packageName] || workspacePackageJson.devDependencies?.[packageName]) {
117566
- return;
117567
- }
117568
- packageJson.dependencies ??= {};
117569
- packageJson.dependencies[packageName] = !!projectGraph.nodes[entry.node.name] ? "latest" : version;
117570
- }
117571
- });
117572
- packageJson.type = "module";
117573
- packageJson.exports ??= {
117574
- ".": {
117575
- import: {
117576
- types: "./dist/modern/index.d.ts",
117577
- default: "./dist/modern/index.js"
117578
- },
117579
- require: {
117580
- types: "./dist/modern/index.d.cts",
117581
- default: "./dist/modern/index.cjs"
117582
- },
117583
- ...(options.additionalEntryPoints ?? []).map((entryPoint) => ({
117584
- [removeExtension(entryPoint).replace(sourceRoot, "")]: {
117585
- types: (0, import_path4.join)(
117586
- "./dist/modern",
117587
- `${removeExtension(entryPoint.replace(sourceRoot, ""))}.d.ts`
117588
- ),
117589
- default: (0, import_path4.join)(
117590
- "./dist/modern",
117591
- `${removeExtension(entryPoint.replace(sourceRoot, ""))}.js`
117592
- )
117593
- }
117594
- }))
117595
- },
117596
- "./package.json": "./package.json"
117597
- };
117598
- packageJson.funding ??= workspacePackageJson.funding;
117599
- packageJson.types ??= "dist/legacy/index.d.ts";
117600
- packageJson.main ??= "dist/legacy/index.cjs";
117601
- packageJson.module ??= "dist/legacy/index.js";
117602
- options.platform && options.platform !== "node" && (packageJson.browser ??= "dist/modern/index.global.js");
117603
- if (options.includeSrc !== false) {
117604
- let distSrc = sourceRoot.replace(projectRoot, "");
117605
- if (distSrc.startsWith("/")) {
117606
- distSrc = distSrc.substring(1);
117607
- }
117608
- packageJson.source ??= `${(0, import_path4.join)(distSrc, "index.ts").replaceAll(
117609
- "\\",
117610
- "/"
117611
- )}`;
117612
- }
117613
- packageJson.sideEffects ??= false;
117614
- packageJson.files ??= ["dist"];
117615
- if (options.includeSrc !== false && !packageJson.files.includes("src")) {
117616
- packageJson.files.push("src");
117617
- }
117618
- packageJson.publishConfig ??= {
117619
- access: "public"
117620
- };
117621
- packageJson.description ??= workspacePackageJson.description;
117622
- packageJson.homepage ??= workspacePackageJson.homepage;
117623
- packageJson.bugs ??= workspacePackageJson.bugs;
117624
- packageJson.author ??= workspacePackageJson.author;
117625
- packageJson.license ??= workspacePackageJson.license;
117626
- packageJson.keywords ??= workspacePackageJson.keywords;
117627
- packageJson.repository ??= workspacePackageJson.repository;
117628
- packageJson.repository.directory ??= projectRoot ? projectRoot : (0, import_path4.join)("packages", context.projectName);
117629
- const packageJsonPath = (0, import_path4.join)(
117630
- context.root,
117631
- options.outputPath,
117632
- "package.json"
117633
- );
117634
- console.log(`\u26A1 Writing package.json file to: ${packageJsonPath}`);
117635
117573
  const prettierOptions = {
117636
117574
  plugins: ["prettier-plugin-packagejson"],
117637
117575
  trailingComma: "none",
@@ -117646,13 +117584,93 @@ ${externalDependencies.map((dep) => {
117646
117584
  arrowParens: "avoid",
117647
117585
  endOfLine: "lf"
117648
117586
  };
117649
- (0, import_fs3.writeFileSync)(
117650
- packageJsonPath,
117651
- await (0, import_prettier.format)(JSON.stringify(packageJson), {
117652
- ...prettierOptions,
117653
- parser: "json"
117654
- })
117655
- );
117587
+ if (options.generatePackageJson !== false) {
117588
+ const projectGraph = (0, import_devkit.readCachedProjectGraph)();
117589
+ const pathToPackageJson = (0, import_path4.join)(context.root, projectRoot, "package.json");
117590
+ const packageJson = (0, import_fileutils.fileExists)(pathToPackageJson) ? (0, import_devkit.readJsonFile)(pathToPackageJson) : { name: context.projectName, version: "0.0.1" };
117591
+ delete packageJson.dependencies;
117592
+ externalDependencies.forEach((entry) => {
117593
+ const packageConfig = entry.node.data;
117594
+ if (packageConfig?.packageName && (!!(projectGraph.externalNodes[entry.node.name]?.type === "npm") || !!projectGraph.nodes[entry.node.name])) {
117595
+ const { packageName, version } = packageConfig;
117596
+ if (workspacePackageJson.dependencies?.[packageName] || workspacePackageJson.devDependencies?.[packageName]) {
117597
+ return;
117598
+ }
117599
+ packageJson.dependencies ??= {};
117600
+ packageJson.dependencies[packageName] = !!projectGraph.nodes[entry.node.name] ? "latest" : version;
117601
+ }
117602
+ });
117603
+ packageJson.type = "module";
117604
+ packageJson.exports ??= {
117605
+ ".": {
117606
+ import: {
117607
+ types: "./dist/modern/index.d.ts",
117608
+ default: "./dist/modern/index.js"
117609
+ },
117610
+ require: {
117611
+ types: "./dist/modern/index.d.cts",
117612
+ default: "./dist/modern/index.cjs"
117613
+ },
117614
+ ...(options.additionalEntryPoints ?? []).map((entryPoint) => ({
117615
+ [removeExtension(entryPoint).replace(sourceRoot, "")]: {
117616
+ types: (0, import_path4.join)(
117617
+ "./dist/modern",
117618
+ `${removeExtension(entryPoint.replace(sourceRoot, ""))}.d.ts`
117619
+ ),
117620
+ default: (0, import_path4.join)(
117621
+ "./dist/modern",
117622
+ `${removeExtension(entryPoint.replace(sourceRoot, ""))}.js`
117623
+ )
117624
+ }
117625
+ }))
117626
+ },
117627
+ "./package.json": "./package.json"
117628
+ };
117629
+ packageJson.funding ??= workspacePackageJson.funding;
117630
+ packageJson.types ??= "dist/legacy/index.d.ts";
117631
+ packageJson.main ??= "dist/legacy/index.cjs";
117632
+ packageJson.module ??= "dist/legacy/index.js";
117633
+ options.platform && options.platform !== "node" && (packageJson.browser ??= "dist/modern/index.global.js");
117634
+ if (options.includeSrc !== false) {
117635
+ let distSrc = sourceRoot.replace(projectRoot, "");
117636
+ if (distSrc.startsWith("/")) {
117637
+ distSrc = distSrc.substring(1);
117638
+ }
117639
+ packageJson.source ??= `${(0, import_path4.join)(distSrc, "index.ts").replaceAll(
117640
+ "\\",
117641
+ "/"
117642
+ )}`;
117643
+ }
117644
+ packageJson.sideEffects ??= false;
117645
+ packageJson.files ??= ["dist"];
117646
+ if (options.includeSrc !== false && !packageJson.files.includes("src")) {
117647
+ packageJson.files.push("src");
117648
+ }
117649
+ packageJson.publishConfig ??= {
117650
+ access: "public"
117651
+ };
117652
+ packageJson.description ??= workspacePackageJson.description;
117653
+ packageJson.homepage ??= workspacePackageJson.homepage;
117654
+ packageJson.bugs ??= workspacePackageJson.bugs;
117655
+ packageJson.author ??= workspacePackageJson.author;
117656
+ packageJson.license ??= workspacePackageJson.license;
117657
+ packageJson.keywords ??= workspacePackageJson.keywords;
117658
+ packageJson.repository ??= workspacePackageJson.repository;
117659
+ packageJson.repository.directory ??= projectRoot ? projectRoot : (0, import_path4.join)("packages", context.projectName);
117660
+ const packageJsonPath = (0, import_path4.join)(
117661
+ context.root,
117662
+ options.outputPath,
117663
+ "package.json"
117664
+ );
117665
+ console.log(`\u26A1 Writing package.json file to: ${packageJsonPath}`);
117666
+ (0, import_fs3.writeFileSync)(
117667
+ packageJsonPath,
117668
+ await (0, import_prettier.format)(JSON.stringify(packageJson), {
117669
+ ...prettierOptions,
117670
+ parser: "json"
117671
+ })
117672
+ );
117673
+ }
117656
117674
  if (options.includeSrc !== false) {
117657
117675
  const files = globSync([
117658
117676
  (0, import_devkit.joinPathFragments)(context.root, options.outputPath, "src/**/*.ts"),
@@ -117794,6 +117812,7 @@ var applyDefaultOptions = (options) => {
117794
117812
  options.entry ??= "{sourceRoot}/index.ts";
117795
117813
  options.outputPath ??= "dist/{projectRoot}";
117796
117814
  options.tsConfig ??= "tsconfig.json";
117815
+ options.generatePackageJson ??= true;
117797
117816
  options.splitting ??= true;
117798
117817
  options.treeshake ??= true;
117799
117818
  options.platform ??= "neutral";