screw-up 1.17.0 → 1.18.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/README.md +4 -0
- package/dist/analyzer.d.ts +2 -2
- package/dist/cli-internal.d.ts +2 -2
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/fast-tags.d.ts +2 -2
- package/dist/generated/packageMetadata.d.ts +4 -4
- package/dist/git-operations.d.ts +2 -2
- package/dist/index.cjs +19 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -129
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/main.cjs +113 -4
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.js +113 -4
- package/dist/main.js.map +1 -1
- package/dist/metadata-file.d.ts +22 -0
- package/dist/metadata-file.d.ts.map +1 -0
- package/dist/{packageMetadata-DdvLnmBC.cjs → packageMetadata-B-eWBZ6y.cjs} +72 -5
- package/dist/packageMetadata-B-eWBZ6y.cjs.map +1 -0
- package/dist/{packageMetadata-DgMEVI8P.js → packageMetadata-BtM7pxOK.js} +78 -11
- package/dist/packageMetadata-BtM7pxOK.js.map +1 -0
- package/dist/types.d.ts +2 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/vite-plugin.d.ts +2 -2
- package/dist/vite-plugin.d.ts.map +1 -1
- package/images/git-versioning.png +0 -0
- package/package.json +9 -8
- package/dist/packageMetadata-DdvLnmBC.cjs.map +0 -1
- package/dist/packageMetadata-DgMEVI8P.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*!
|
|
3
3
|
* name: screw-up
|
|
4
|
-
* version: 1.
|
|
4
|
+
* version: 1.18.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:
|
|
9
|
+
* git.commit.hash: 104b6e6ab47e8c328ae5d6883f7931b0eea4f5cd
|
|
10
10
|
*/
|
|
11
11
|
import { join, dirname, resolve } from "path";
|
|
12
12
|
import { createWriteStream, createReadStream, existsSync } from "fs";
|
|
@@ -16,7 +16,7 @@ import { tmpdir } from "os";
|
|
|
16
16
|
import { Readable } from "stream";
|
|
17
17
|
import { createGunzip, createGzip } from "zlib";
|
|
18
18
|
import { pipeline } from "stream/promises";
|
|
19
|
-
import {
|
|
19
|
+
import { d as resolveRawPackageJsonObject, f as findWorkspaceRoot, h as collectWorkspaceSiblings, i as replacePeerDependenciesWildcards, g as getFetchGitMetadata, r as resolvePackageMetadata, b as generateMetadataFileContent, w as writeFileIfChanged, e as ensureMetadataGitignore, c as createConsoleLogger, n as name } from "./packageMetadata-BtM7pxOK.js";
|
|
20
20
|
/*!
|
|
21
21
|
* name: tar-vern
|
|
22
22
|
* version: 1.3.0
|
|
@@ -848,6 +848,15 @@ const defaultInheritableFields = /* @__PURE__ */ new Set([
|
|
|
848
848
|
"bugs",
|
|
849
849
|
"readme"
|
|
850
850
|
]);
|
|
851
|
+
const defaultOutputMetadataKeys = [
|
|
852
|
+
"name",
|
|
853
|
+
"version",
|
|
854
|
+
"description",
|
|
855
|
+
"author",
|
|
856
|
+
"license",
|
|
857
|
+
"repository.url",
|
|
858
|
+
"git.commit.hash"
|
|
859
|
+
];
|
|
851
860
|
const parseInheritableFields = (inheritableFieldsOption) => {
|
|
852
861
|
if (typeof inheritableFieldsOption !== "string") {
|
|
853
862
|
return defaultInheritableFields;
|
|
@@ -859,6 +868,15 @@ const parseInheritableFields = (inheritableFieldsOption) => {
|
|
|
859
868
|
inheritableFieldsOption.split(",").map((field) => field.trim()).filter((field) => field.length > 0)
|
|
860
869
|
);
|
|
861
870
|
};
|
|
871
|
+
const parseOutputMetadataKeys = (outputMetadataKeysOption) => {
|
|
872
|
+
if (typeof outputMetadataKeysOption !== "string") {
|
|
873
|
+
return defaultOutputMetadataKeys;
|
|
874
|
+
}
|
|
875
|
+
if (!outputMetadataKeysOption.trim()) {
|
|
876
|
+
return [];
|
|
877
|
+
}
|
|
878
|
+
return outputMetadataKeysOption.split(",").map((key) => key.trim()).filter((key) => key.length > 0);
|
|
879
|
+
};
|
|
862
880
|
const readInputText = async (inputPath) => {
|
|
863
881
|
if (inputPath) {
|
|
864
882
|
const resolvedPath = resolve(inputPath);
|
|
@@ -1081,6 +1099,92 @@ const dumpCommand = async (args, logger2) => {
|
|
|
1081
1099
|
}
|
|
1082
1100
|
return 0;
|
|
1083
1101
|
};
|
|
1102
|
+
const showMetadataHelp = () => {
|
|
1103
|
+
console.info(`Usage: screw-up metadata [options] [directory]
|
|
1104
|
+
|
|
1105
|
+
Generate TypeScript metadata file from package metadata
|
|
1106
|
+
|
|
1107
|
+
Arguments:
|
|
1108
|
+
directory Directory to resolve metadata from (default: current directory)
|
|
1109
|
+
|
|
1110
|
+
Options:
|
|
1111
|
+
--output-metadata-file-path <path> Output path for metadata file (default: src/generated/packageMetadata.ts)
|
|
1112
|
+
--output-metadata-keys <list> Comma-separated list of metadata keys to include
|
|
1113
|
+
--no-wds Do not check working directory status to increase version
|
|
1114
|
+
--no-git-version-override Do not override version from Git (use package.json version)
|
|
1115
|
+
-h, --help Show help for metadata command
|
|
1116
|
+
`);
|
|
1117
|
+
};
|
|
1118
|
+
const metadataCommand = async (args, logger2) => {
|
|
1119
|
+
if (args.options.help || args.options.h) {
|
|
1120
|
+
showMetadataHelp();
|
|
1121
|
+
return 1;
|
|
1122
|
+
}
|
|
1123
|
+
const directory = args.positional[0];
|
|
1124
|
+
const outputMetadataFilePathOption = args.options["output-metadata-file-path"];
|
|
1125
|
+
const outputMetadataKeysOption = args.options["output-metadata-keys"];
|
|
1126
|
+
const alwaysOverrideVersionFromGit = !args.options["no-git-version-override"];
|
|
1127
|
+
const checkWorkingDirectoryStatus = args.options["no-wds"] ? false : true;
|
|
1128
|
+
const outputMetadataFilePath = typeof outputMetadataFilePathOption === "string" && outputMetadataFilePathOption.trim() ? outputMetadataFilePathOption : "src/generated/packageMetadata.ts";
|
|
1129
|
+
const outputMetadataKeys = parseOutputMetadataKeys(outputMetadataKeysOption);
|
|
1130
|
+
const targetDir = resolve(directory != null ? directory : process.cwd());
|
|
1131
|
+
try {
|
|
1132
|
+
const fetchGitMetadata = getFetchGitMetadata(
|
|
1133
|
+
targetDir,
|
|
1134
|
+
checkWorkingDirectoryStatus,
|
|
1135
|
+
logger2
|
|
1136
|
+
);
|
|
1137
|
+
const result = await resolvePackageMetadata(
|
|
1138
|
+
targetDir,
|
|
1139
|
+
fetchGitMetadata,
|
|
1140
|
+
alwaysOverrideVersionFromGit,
|
|
1141
|
+
logger2
|
|
1142
|
+
);
|
|
1143
|
+
const metadataSourceContent = generateMetadataFileContent(
|
|
1144
|
+
result.metadata,
|
|
1145
|
+
outputMetadataKeys
|
|
1146
|
+
);
|
|
1147
|
+
const metadataSourcePath = join(targetDir, outputMetadataFilePath);
|
|
1148
|
+
const metadataWritten = await writeFileIfChanged(
|
|
1149
|
+
metadataSourcePath,
|
|
1150
|
+
metadataSourceContent,
|
|
1151
|
+
"metadata source file",
|
|
1152
|
+
logger2
|
|
1153
|
+
);
|
|
1154
|
+
if (existsSync(metadataSourcePath)) {
|
|
1155
|
+
const gitignoreWritten = await ensureMetadataGitignore(
|
|
1156
|
+
metadataSourcePath,
|
|
1157
|
+
logger2
|
|
1158
|
+
);
|
|
1159
|
+
if (gitignoreWritten) {
|
|
1160
|
+
logger2.info(
|
|
1161
|
+
`metadata: .gitignore is generated: ${join(
|
|
1162
|
+
dirname(outputMetadataFilePath),
|
|
1163
|
+
".gitignore"
|
|
1164
|
+
)}`
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
if (metadataWritten) {
|
|
1169
|
+
logger2.info(
|
|
1170
|
+
`metadata: Metadata source file is generated: ${outputMetadataFilePath}`
|
|
1171
|
+
);
|
|
1172
|
+
} else if (existsSync(metadataSourcePath)) {
|
|
1173
|
+
logger2.info(
|
|
1174
|
+
`metadata: Metadata source file is unchanged: ${outputMetadataFilePath}`
|
|
1175
|
+
);
|
|
1176
|
+
} else {
|
|
1177
|
+
logger2.error(
|
|
1178
|
+
`metadata: Failed to write metadata file: ${outputMetadataFilePath}`
|
|
1179
|
+
);
|
|
1180
|
+
return 1;
|
|
1181
|
+
}
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
logger2.error(`metadata: Failed to generate metadata file: ${error}`);
|
|
1184
|
+
return 1;
|
|
1185
|
+
}
|
|
1186
|
+
return 0;
|
|
1187
|
+
};
|
|
1084
1188
|
const showPackHelp = () => {
|
|
1085
1189
|
console.info(`Usage: screw-up pack [options] [directory]
|
|
1086
1190
|
|
|
@@ -1327,7 +1431,7 @@ const publishCommand = async (args, logger2) => {
|
|
|
1327
1431
|
}
|
|
1328
1432
|
};
|
|
1329
1433
|
const showHelp = async () => {
|
|
1330
|
-
const { author, license, repository_url, version, git_commit_hash } = await import("./packageMetadata-
|
|
1434
|
+
const { author, license, repository_url, version, git_commit_hash } = await import("./packageMetadata-BtM7pxOK.js").then((n) => n.p);
|
|
1331
1435
|
console.info(`screw-up [${version}-${git_commit_hash}]
|
|
1332
1436
|
Easy package metadata inserter CLI
|
|
1333
1437
|
Copyright (c) ${author}
|
|
@@ -1339,6 +1443,7 @@ Usage: screw-up <command> [options]
|
|
|
1339
1443
|
Commands:
|
|
1340
1444
|
format [output] Format text by replacing metadata placeholders
|
|
1341
1445
|
dump [directory] Dump computed package.json as JSON
|
|
1446
|
+
metadata [directory] Generate TypeScript metadata file
|
|
1342
1447
|
pack [directory] Pack the project into a tar archive
|
|
1343
1448
|
publish [directory|package.tgz] Publish the project
|
|
1344
1449
|
|
|
@@ -1348,6 +1453,7 @@ Options:
|
|
|
1348
1453
|
Examples:
|
|
1349
1454
|
screw-up format output.txt # Format stdin template and write to file
|
|
1350
1455
|
screw-up dump # Dump computed package.json as JSON
|
|
1456
|
+
screw-up metadata # Generate metadata file
|
|
1351
1457
|
screw-up pack # Pack current directory
|
|
1352
1458
|
screw-up pack --pack-destination ./dist # Pack to specific output directory
|
|
1353
1459
|
screw-up publish # Publish current directory
|
|
@@ -1356,6 +1462,7 @@ Examples:
|
|
|
1356
1462
|
};
|
|
1357
1463
|
const argOptionMap = /* @__PURE__ */ new Map([
|
|
1358
1464
|
["dump", /* @__PURE__ */ new Set(["inheritable-fields"])],
|
|
1465
|
+
["metadata", /* @__PURE__ */ new Set(["output-metadata-file-path", "output-metadata-keys"])],
|
|
1359
1466
|
[
|
|
1360
1467
|
"pack",
|
|
1361
1468
|
/* @__PURE__ */ new Set([
|
|
@@ -1379,6 +1486,8 @@ const cliMain = async (args, logger2) => {
|
|
|
1379
1486
|
return await formatCommand(parsedArgs, logger2);
|
|
1380
1487
|
case "dump":
|
|
1381
1488
|
return await dumpCommand(parsedArgs, logger2);
|
|
1489
|
+
case "metadata":
|
|
1490
|
+
return await metadataCommand(parsedArgs, logger2);
|
|
1382
1491
|
case "pack":
|
|
1383
1492
|
return await packCommand(parsedArgs, logger2);
|
|
1384
1493
|
case "publish":
|