onreza-release 2.0.0 → 2.1.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/dist/cli.js CHANGED
@@ -2740,6 +2740,8 @@ function getBinarySourcePath(config, platform) {
2740
2740
  }
2741
2741
 
2742
2742
  // src/utils/binary-postinstall-generator.ts
2743
+ import { mkdir, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
2744
+ import { join } from "node:path";
2743
2745
  function generatePostinstallScript(manifest) {
2744
2746
  return `#!/usr/bin/env node
2745
2747
  "use strict";
@@ -2873,6 +2875,88 @@ function generateMasterPackageJson(name, version, binName, description) {
2873
2875
  };
2874
2876
  return JSON.stringify(pkg, null, 2);
2875
2877
  }
2878
+ async function writeNpmFiles(options) {
2879
+ const { manifest, binName, npmConfig, baseDir = ".", dryRun = false } = options;
2880
+ const scriptsDir = join(baseDir, npmConfig.scriptsDir);
2881
+ const binDir = join(baseDir, npmConfig.binDir);
2882
+ const postinstallPath = join(scriptsDir, "postinstall.js");
2883
+ const binWrapperPath = join(binDir, `${binName}.js`);
2884
+ const postinstallContent = generatePostinstallScript(manifest);
2885
+ const binWrapperContent = generateBinWrapper(binName);
2886
+ if (dryRun) {
2887
+ console.log(`
2888
+ \uD83D\uDCDD Would write postinstall script to: ${postinstallPath}`);
2889
+ console.log(`\uD83D\uDCDD Would write bin wrapper to: ${binWrapperPath}`);
2890
+ } else {
2891
+ await mkdir(scriptsDir, { recursive: true });
2892
+ await mkdir(binDir, { recursive: true });
2893
+ await writeFile3(postinstallPath, postinstallContent, "utf-8");
2894
+ await writeFile3(binWrapperPath, binWrapperContent, { encoding: "utf-8", mode: 493 });
2895
+ console.log(`✅ Created postinstall script: ${postinstallPath}`);
2896
+ console.log(`✅ Created bin wrapper: ${binWrapperPath}`);
2897
+ }
2898
+ let packageJsonUpdated = false;
2899
+ if (npmConfig.updatePackageJson) {
2900
+ packageJsonUpdated = await updatePackageJsonForBinaries({
2901
+ baseDir,
2902
+ binDir: npmConfig.binDir,
2903
+ binName,
2904
+ dryRun,
2905
+ scriptsDir: npmConfig.scriptsDir
2906
+ });
2907
+ }
2908
+ return {
2909
+ binWrapperPath,
2910
+ packageJsonUpdated,
2911
+ postinstallPath
2912
+ };
2913
+ }
2914
+ async function updatePackageJsonForBinaries(options) {
2915
+ const { baseDir, binName, scriptsDir, binDir, dryRun = false } = options;
2916
+ const packageJsonPath = join(baseDir, "package.json");
2917
+ try {
2918
+ const content = await readFile5(packageJsonPath, "utf-8");
2919
+ const pkg = JSON.parse(content);
2920
+ let modified = false;
2921
+ const expectedBin = `${binDir}/${binName}.js`;
2922
+ if (!pkg.bin || pkg.bin[binName] !== expectedBin) {
2923
+ pkg.bin = pkg.bin || {};
2924
+ pkg.bin[binName] = expectedBin;
2925
+ modified = true;
2926
+ }
2927
+ const expectedPostinstall = `node ${scriptsDir}/postinstall.js`;
2928
+ if (!pkg.scripts?.postinstall || pkg.scripts.postinstall !== expectedPostinstall) {
2929
+ pkg.scripts = pkg.scripts || {};
2930
+ pkg.scripts.postinstall = expectedPostinstall;
2931
+ modified = true;
2932
+ }
2933
+ if (pkg.files && Array.isArray(pkg.files)) {
2934
+ if (!pkg.files.includes(scriptsDir)) {
2935
+ pkg.files.push(scriptsDir);
2936
+ modified = true;
2937
+ }
2938
+ if (!pkg.files.includes(binDir)) {
2939
+ pkg.files.push(binDir);
2940
+ modified = true;
2941
+ }
2942
+ }
2943
+ if (modified) {
2944
+ if (dryRun) {
2945
+ console.log("\uD83D\uDCDD Would update package.json with bin and scripts.postinstall");
2946
+ } else {
2947
+ await writeFile3(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
2948
+ `, "utf-8");
2949
+ console.log("✅ Updated package.json with bin and scripts.postinstall");
2950
+ }
2951
+ return true;
2952
+ }
2953
+ console.log("ℹ️ package.json already has correct bin and scripts.postinstall");
2954
+ return false;
2955
+ } catch (error) {
2956
+ console.warn(`⚠️ Could not update package.json: ${error instanceof Error ? error.message : String(error)}`);
2957
+ return false;
2958
+ }
2959
+ }
2876
2960
 
2877
2961
  // src/binaries.ts
2878
2962
  function sleep2(ms) {
@@ -3009,14 +3093,35 @@ async function publishBinaries(options = {}) {
3009
3093
  }
3010
3094
  const binName = binariesConfig.binName ?? binariesConfig.name;
3011
3095
  const manifest = createBinaryManifest(version, binName, assets);
3012
- console.log(`
3096
+ if (binariesConfig.npm?.generateScripts !== false) {
3097
+ const npmConfig = {
3098
+ binDir: binariesConfig.npm?.binDir ?? "bin",
3099
+ generateScripts: binariesConfig.npm?.generateScripts ?? true,
3100
+ scriptsDir: binariesConfig.npm?.scriptsDir ?? "scripts",
3101
+ updatePackageJson: binariesConfig.npm?.updatePackageJson ?? true
3102
+ };
3103
+ console.log(`
3104
+ \uD83D\uDCE6 Generating npm distribution files...`);
3105
+ await writeNpmFiles({
3106
+ binName,
3107
+ manifest,
3108
+ npmConfig
3109
+ });
3110
+ console.log(`
3111
+ \uD83D\uDCA1 Next steps:`);
3112
+ console.log(" 1. Review generated files in scripts/ and bin/");
3113
+ console.log(" 2. Run: npm publish (or bun publish)");
3114
+ console.log(` 3. Users install with: npm install ${binariesConfig.name}`);
3115
+ } else {
3116
+ console.log(`
3013
3117
  \uD83D\uDCDD Generated manifest:`);
3014
- console.log(JSON.stringify(manifest, null, 2));
3015
- console.log(`
3118
+ console.log(JSON.stringify(manifest, null, 2));
3119
+ console.log(`
3016
3120
  \uD83D\uDCDC Postinstall script:`);
3017
- console.log("---");
3018
- console.log(generatePostinstallScript(manifest));
3019
- console.log("---");
3121
+ console.log("---");
3122
+ console.log(generatePostinstallScript(manifest));
3123
+ console.log("---");
3124
+ }
3020
3125
  }
3021
3126
  result.success = successfulUploads.length > 0;
3022
3127
  if (result.success) {
@@ -3111,6 +3216,17 @@ function printDryRun(config, version, platforms) {
3111
3216
  console.log(` Max files per upload: ${GITVERSE_ASSET_LIMITS.maxFilesPerUpload}`);
3112
3217
  console.log(` Max total size: ${formatFileSize2(GITVERSE_ASSET_LIMITS.maxTotalSizeBytes)}`);
3113
3218
  console.log(" Note: Actual limits depend on detected platform");
3219
+ if (config.npm?.generateScripts !== false) {
3220
+ const scriptsDir = config.npm?.scriptsDir ?? "scripts";
3221
+ const binDir = config.npm?.binDir ?? "bin";
3222
+ console.log(`
3223
+ \uD83D\uDCDD NPM distribution files to generate:`);
3224
+ console.log(` Postinstall script: ${scriptsDir}/postinstall.js`);
3225
+ console.log(` Bin wrapper: ${binDir}/${binName}.js`);
3226
+ if (config.npm?.updatePackageJson !== false) {
3227
+ console.log(" package.json: will be updated with bin and scripts.postinstall");
3228
+ }
3229
+ }
3114
3230
  }
3115
3231
 
3116
3232
  // src/index.ts
@@ -3419,7 +3535,7 @@ async function createReleaseOnly(tag, packageName, configPath) {
3419
3535
  import { parseArgs } from "node:util";
3420
3536
 
3421
3537
  // src/utils/commitlint-generator.ts
3422
- import { writeFile as writeFile3 } from "node:fs/promises";
3538
+ import { writeFile as writeFile4 } from "node:fs/promises";
3423
3539
  async function generateCommitlint(config, options = {}) {
3424
3540
  const generatorOptions = parseGeneratorOptions(options);
3425
3541
  const rules = buildCommitlintRules(config, options);
@@ -3431,7 +3547,7 @@ async function generateCommitlint(config, options = {}) {
3431
3547
  printDryRunOutput(configContent, generatorOptions.output);
3432
3548
  return;
3433
3549
  }
3434
- await writeFile3(generatorOptions.output, configContent);
3550
+ await writeFile4(generatorOptions.output, configContent);
3435
3551
  console.log(`✅ Generated commitlint config: ${generatorOptions.output}`);
3436
3552
  }
3437
3553
  function parseGeneratorOptions(options) {
@@ -3938,4 +4054,4 @@ Usage: onreza-release create-only --tag <tag> [--package <name>]`);
3938
4054
  }
3939
4055
  main();
3940
4056
 
3941
- //# debugId=FB2A0179923A9C4764756E2164756E21
4057
+ //# debugId=C4492F97E2DD6CFF64756E2164756E21