screw-up 1.33.0 → 1.35.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/main.cjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  /*!
3
3
  * name: screw-up
4
- * version: 1.33.0
4
+ * version: 1.35.0
5
5
  * description: Simply package metadata inserter on Vite plugin
6
6
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
7
7
  * license: MIT
8
8
  * repository.url: https://github.com/kekyo/screw-up.git
9
- * git.commit.hash: be56ff1901b5073e1b0238a28b80d0c4f3c1e894
9
+ * git.commit.hash: b059d6107487ef2a79821547868082a7b5374fd7
10
10
  */
11
11
  //#region \0rolldown/runtime.js
12
12
  var __create = Object.create;
@@ -15,7 +15,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
15
  var __getOwnPropNames = Object.getOwnPropertyNames;
16
16
  var __getProtoOf = Object.getPrototypeOf;
17
17
  var __hasOwnProp = Object.prototype.hasOwnProperty;
18
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
19
19
  var __copyProps = (to, from, except, desc) => {
20
20
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
21
21
  key = keys[i];
@@ -31,7 +31,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  enumerable: true
32
32
  }) : target, mod));
33
33
  //#endregion
34
- const require_packageMetadata = require("./packageMetadata-k_QXJ2PH.cjs");
35
34
  let path = require("path");
36
35
  let fs = require("fs");
37
36
  let fs_promises = require("fs/promises");
@@ -2787,14 +2786,14 @@ var collectTreeFiles = async (resolver, treeOid, prefix, files) => {
2787
2786
  await collectTreeFiles(resolver, entry.oid, path$7, files);
2788
2787
  continue;
2789
2788
  }
2790
- if (entry.mode !== "160000") files.set(path$7, entry.oid);
2789
+ files.set(path$7, entry.oid);
2791
2790
  }
2792
2791
  };
2793
2792
  /**
2794
- * Collect all tracked file blob OIDs under the specified tree.
2793
+ * Collect all tracked file and submodule OIDs under the specified tree.
2795
2794
  * @param repoPath - Repository path
2796
2795
  * @param treeOid - Tree object OID
2797
- * @returns Map of repository-relative file path to blob OID
2796
+ * @returns Map of repository-relative file path to blob or submodule OID
2798
2797
  */
2799
2798
  var listTreeFiles = async (repoPath, treeOid) => {
2800
2799
  const resolver = await createGitObjectResolver(repoPath);
@@ -3215,6 +3214,9 @@ var getRelatedBranches = async (context, commitHash) => {
3215
3214
  return [];
3216
3215
  }
3217
3216
  };
3217
+ var GITLINK_INDEX_MODE = 57344;
3218
+ var INDEX_MODE_TYPE_MASK = 61440;
3219
+ var isGitLinkIndexEntry = (entry) => (entry.mode & INDEX_MODE_TYPE_MASK) === GITLINK_INDEX_MODE;
3218
3220
  var parseGitIndex = async (gitDir) => {
3219
3221
  try {
3220
3222
  const buffer = await fs_promises.default.readFile((0, path.join)(gitDir, "index"));
@@ -3226,6 +3228,7 @@ var parseGitIndex = async (gitDir) => {
3226
3228
  const entries = /* @__PURE__ */ new Map();
3227
3229
  for (let index = 0; index < entryCount; index++) {
3228
3230
  const entryStart = offset;
3231
+ const mode = buffer.readUInt32BE(entryStart + 24);
3229
3232
  const size = buffer.readUInt32BE(entryStart + 36);
3230
3233
  const oid = buffer.subarray(entryStart + 40, entryStart + 60).toString("hex");
3231
3234
  const flags = buffer.readUInt16BE(entryStart + 60);
@@ -3240,6 +3243,7 @@ var parseGitIndex = async (gitDir) => {
3240
3243
  entries.set(path$3, {
3241
3244
  path: path$3,
3242
3245
  oid,
3246
+ mode,
3243
3247
  size,
3244
3248
  stage
3245
3249
  });
@@ -3262,7 +3266,7 @@ var listTrackedDirectories = (indexEntries) => {
3262
3266
  }
3263
3267
  return directories;
3264
3268
  };
3265
- var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relativePath = "") => {
3269
+ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, excludedDirectories, relativePath = "") => {
3266
3270
  const directoryPath = relativePath ? (0, path.join)(repositoryPath, relativePath) : repositoryPath;
3267
3271
  const entries = await fs_promises.default.readdir(directoryPath, { withFileTypes: true });
3268
3272
  const files = [];
@@ -3270,6 +3274,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
3270
3274
  if (entry.name === ".git") continue;
3271
3275
  const entryPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
3272
3276
  if (entry.isDirectory()) {
3277
+ if (excludedDirectories.has(entryPath)) continue;
3273
3278
  if (!trackedDirectories.has(entryPath)) {
3274
3279
  if (await isomorphic_git.isIgnored({
3275
3280
  fs: fs_promises.default,
@@ -3277,7 +3282,7 @@ var listWorkingDirectoryFiles = async (repositoryPath, trackedDirectories, relat
3277
3282
  filepath: entryPath
3278
3283
  })) continue;
3279
3284
  }
3280
- files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, entryPath));
3285
+ files.push(...await listWorkingDirectoryFiles(repositoryPath, trackedDirectories, excludedDirectories, entryPath));
3281
3286
  continue;
3282
3287
  }
3283
3288
  if (entry.isFile() || entry.isSymbolicLink()) files.push(entryPath);
@@ -3292,7 +3297,7 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
3292
3297
  try {
3293
3298
  const gitDir = await getActualGitDir(repositoryPath);
3294
3299
  const [headFiles, indexEntries] = await Promise.all([listTreeFiles(repositoryPath, headTreeOid), parseGitIndex(gitDir)]);
3295
- const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries));
3300
+ const workdirFiles = await listWorkingDirectoryFiles(repositoryPath, listTrackedDirectories(indexEntries), new Set(Array.from(indexEntries.values()).filter(isGitLinkIndexEntry).map((entry) => entry.path)));
3296
3301
  const modifiedFiles = /* @__PURE__ */ new Map();
3297
3302
  const rememberModifiedFile = (path$5, reason) => {
3298
3303
  if (!modifiedFiles.has(path$5)) modifiedFiles.set(path$5, {
@@ -3310,6 +3315,10 @@ var getModifiedFiles = async (repositoryPath, headTreeOid) => {
3310
3315
  const absolutePath = (0, path.join)(repositoryPath, indexEntry.path);
3311
3316
  try {
3312
3317
  const stats = await fs_promises.default.lstat(absolutePath);
3318
+ if (isGitLinkIndexEntry(indexEntry)) {
3319
+ if (indexEntry.stage !== 0) rememberModifiedFile(indexEntry.path, "staged");
3320
+ continue;
3321
+ }
3313
3322
  if (!stats.isFile() && !stats.isSymbolicLink()) {
3314
3323
  rememberModifiedFile(indexEntry.path, "worktree");
3315
3324
  continue;
@@ -3927,6 +3936,13 @@ var ensureMetadataGitignore = async (metadataSourcePath, logger) => {
3927
3936
  }
3928
3937
  };
3929
3938
  //#endregion
3939
+ //#region src/generated/packageMetadata.ts
3940
+ var name = "screw-up";
3941
+ var version = "1.35.0";
3942
+ var author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
3943
+ var repository_url = "https://github.com/kekyo/screw-up.git";
3944
+ var git_commit_hash = "b059d6107487ef2a79821547868082a7b5374fd7";
3945
+ //#endregion
3930
3946
  //#region src/cli.ts
3931
3947
  var defaultInheritableFields = new Set([
3932
3948
  "version",
@@ -4005,6 +4021,7 @@ Arguments:
4005
4021
  output Optional output file path (default: stdout)
4006
4022
 
4007
4023
  Options:
4024
+ -e, --expression <text> Input template text directly
4008
4025
  -i, --input <path> Input template file (default: stdin)
4009
4026
  -b, --bracket <open,close> Placeholder brackets (default: {,})
4010
4027
  --inheritable-fields <list> Comma-separated list of fields to inherit from parent
@@ -4030,18 +4047,25 @@ var parseBracketOption = (bracketOption) => {
4030
4047
  };
4031
4048
  };
4032
4049
  var formatCommand = async (args, logger) => {
4033
- var _args$options$input, _args$options$bracket;
4050
+ var _args$options$input, _args$options$express, _args$options$bracket;
4034
4051
  if (args.options.help || args.options.h) {
4035
4052
  showFormatHelp();
4036
4053
  return 1;
4037
4054
  }
4038
4055
  const outputPath = args.positional[0];
4039
4056
  const inputPathOption = (_args$options$input = args.options["input"]) !== null && _args$options$input !== void 0 ? _args$options$input : args.options["i"];
4057
+ const expressionOption = (_args$options$express = args.options["expression"]) !== null && _args$options$express !== void 0 ? _args$options$express : args.options["e"];
4040
4058
  const bracketOption = (_args$options$bracket = args.options["bracket"]) !== null && _args$options$bracket !== void 0 ? _args$options$bracket : args.options["b"];
4041
4059
  const inheritableFieldsOption = args.options["inheritable-fields"];
4042
4060
  const alwaysOverrideVersionFromGit = !args.options["no-git-version-override"];
4043
4061
  const checkWorkingDirectoryStatus = args.options["no-wds"] ? false : true;
4044
4062
  const ignorePackageJsonNotExist = args.options["force"] || args.options["f"] ? true : false;
4063
+ const inputPath = typeof inputPathOption === "string" ? inputPathOption : void 0;
4064
+ const expression = typeof expressionOption === "string" ? expressionOption : void 0;
4065
+ if (inputPath !== void 0 && expression !== void 0) {
4066
+ logger.error("format: Specify only one input source: -e/--expression or -i/--input.");
4067
+ return 1;
4068
+ }
4045
4069
  const bracket = parseBracketOption(typeof bracketOption === "string" ? bracketOption : void 0);
4046
4070
  if (!bracket) {
4047
4071
  logger.error("format: Invalid bracket option, expected \"open,close\" pattern.");
@@ -4062,7 +4086,7 @@ var formatCommand = async (args, logger) => {
4062
4086
  _logger.error(`format: Unable to read package.json from: ${targetDir}`);
4063
4087
  return 1;
4064
4088
  }
4065
- const formattedText = replacePlaceholders(await readInputText(typeof inputPathOption === "string" ? inputPathOption : void 0), computedPackageJson, openBracket, closeBracket);
4089
+ const formattedText = replacePlaceholders(expression !== null && expression !== void 0 ? expression : await readInputText(inputPath), computedPackageJson, openBracket, closeBracket);
4066
4090
  if (outputPath) await (0, fs_promises.writeFile)((0, path.resolve)(outputPath), formattedText);
4067
4091
  process.stdout.write(formattedText);
4068
4092
  } catch (error) {
@@ -4371,12 +4395,11 @@ var publishCommand = async (args, logger) => {
4371
4395
  }
4372
4396
  };
4373
4397
  var showHelp = async () => {
4374
- const { author, license, repository_url, version, git_commit_hash } = await Promise.resolve().then(() => require("./packageMetadata-CaaD3Ehh.cjs"));
4375
4398
  console.info(`screw-up [${version}-${git_commit_hash}]
4376
4399
  Easy package metadata inserter CLI
4377
4400
  Copyright (c) ${author}
4378
4401
  Repository: ${repository_url}
4379
- License: ${license}
4402
+ License: MIT
4380
4403
 
4381
4404
  Usage: screw-up <command> [options]
4382
4405
 
@@ -4410,6 +4433,8 @@ var argOptionMap = new Map([
4410
4433
  "peer-deps-prefix"
4411
4434
  ])],
4412
4435
  ["format", new Set([
4436
+ "expression",
4437
+ "e",
4413
4438
  "input",
4414
4439
  "i",
4415
4440
  "bracket",
@@ -4439,7 +4464,7 @@ var cliMain = async (args, logger) => {
4439
4464
  };
4440
4465
  //#endregion
4441
4466
  //#region src/main.ts
4442
- var logger = createConsoleLogger(`${require_packageMetadata.name}-cli`);
4467
+ var logger = createConsoleLogger(`${name}-cli`);
4443
4468
  cliMain(process.argv.slice(2), logger).then((code) => process.exit(code)).catch((error) => {
4444
4469
  logger.error(`CLI error: ${error}`);
4445
4470
  process.exit(1);