screw-up 1.1.0 → 1.2.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/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/generated/packageMetadata.d.ts +4 -4
- package/dist/index.cjs +294 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +293 -26
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +7 -5
- package/dist/internal.d.ts.map +1 -1
- package/dist/main.cjs +50 -48
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.js +51 -49
- package/dist/main.js.map +1 -1
- package/dist/{analyzer-DtoN0my1.cjs → packageMetadata-Bg66jaR4.cjs} +107 -73
- package/dist/packageMetadata-Bg66jaR4.cjs.map +1 -0
- package/dist/{analyzer-BIXh0cn6.js → packageMetadata-DOzhlPbz.js} +111 -77
- package/dist/packageMetadata-DOzhlPbz.js.map +1 -0
- package/dist/types.d.ts +7 -2
- 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/package.json +11 -9
- package/dist/analyzer-BIXh0cn6.js.map +0 -1
- package/dist/analyzer-DtoN0my1.cjs.map +0 -1
- package/dist/packageMetadata-C-jcs8Th.js +0 -20
- package/dist/packageMetadata-C-jcs8Th.js.map +0 -1
- package/dist/packageMetadata-Hteuv2eS.cjs +0 -20
- package/dist/packageMetadata-Hteuv2eS.cjs.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.2.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: cc82696555da70d209bcd4d7ca6cba330360e074
|
|
10
10
|
*/
|
|
11
11
|
import { join, dirname, resolve } from "path";
|
|
12
12
|
import { createWriteStream, createReadStream, existsSync } from "fs";
|
|
@@ -16,15 +16,15 @@ 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 { b as resolveRawPackageJsonObject, f as findWorkspaceRoot, d as collectWorkspaceSiblings, e as replacePeerDependenciesWildcards, g as getFetchGitMetadata, c as createConsoleLogger, n as name } from "./packageMetadata-DOzhlPbz.js";
|
|
20
20
|
/*!
|
|
21
21
|
* name: tar-vern
|
|
22
|
-
* version: 1.
|
|
22
|
+
* version: 1.3.0
|
|
23
23
|
* description: Tape archiver library for Typescript
|
|
24
24
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
25
25
|
* license: MIT
|
|
26
26
|
* repository.url: https://github.com/kekyo/tar-vern.git
|
|
27
|
-
* git.commit.hash:
|
|
27
|
+
* git.commit.hash: 7ac8b1f258e17c93767650ef047a2db9f0ffd417
|
|
28
28
|
*/
|
|
29
29
|
const MAX_NAME = 100;
|
|
30
30
|
const MAX_PREFIX = 155;
|
|
@@ -241,15 +241,15 @@ const splitPath = (path) => {
|
|
|
241
241
|
return { prefix: "", name: path };
|
|
242
242
|
}
|
|
243
243
|
const parts = path.split("/");
|
|
244
|
-
let
|
|
244
|
+
let name2 = (_a = parts.pop()) != null ? _a : "";
|
|
245
245
|
let prefix = parts.join("/");
|
|
246
|
-
if (utf8ByteLength(
|
|
247
|
-
|
|
246
|
+
if (utf8ByteLength(name2) > MAX_NAME) {
|
|
247
|
+
name2 = truncateUtf8Safe(name2, MAX_NAME);
|
|
248
248
|
}
|
|
249
249
|
while (utf8ByteLength(prefix) > MAX_PREFIX) {
|
|
250
250
|
prefix = truncateUtf8Safe(prefix, MAX_PREFIX);
|
|
251
251
|
}
|
|
252
|
-
return { prefix, name };
|
|
252
|
+
return { prefix, name: name2 };
|
|
253
253
|
};
|
|
254
254
|
const getOctalBytes = (value, length) => {
|
|
255
255
|
const str = value.toString(8).padStart(length - 1, "0") + "\0";
|
|
@@ -266,8 +266,8 @@ const getPaddedBytes = (buffer) => {
|
|
|
266
266
|
const terminatorBytes = Buffer.alloc(1024, 0);
|
|
267
267
|
const createTarHeader = (type, path, size, mode, uname, gname, uid, gid, date) => {
|
|
268
268
|
const buffer = Buffer.alloc(512, 0);
|
|
269
|
-
const { name, prefix } = splitPath(path);
|
|
270
|
-
buffer.write(
|
|
269
|
+
const { name: name2, prefix } = splitPath(path);
|
|
270
|
+
buffer.write(name2, 0, 100, "utf8");
|
|
271
271
|
getOctalBytes(mode & 4095, 8).copy(buffer, 100);
|
|
272
272
|
getOctalBytes(uid, 8).copy(buffer, 108);
|
|
273
273
|
getOctalBytes(gid, 8).copy(buffer, 116);
|
|
@@ -450,7 +450,7 @@ const parseTarHeader = (buffer) => {
|
|
|
450
450
|
if (buffer.every((b) => b === 0)) {
|
|
451
451
|
return void 0;
|
|
452
452
|
}
|
|
453
|
-
const
|
|
453
|
+
const name2 = parseString(buffer, 0, 100);
|
|
454
454
|
const mode = parseOctalBytes(buffer, 100, 8);
|
|
455
455
|
const uid = parseOctalBytes(buffer, 108, 8);
|
|
456
456
|
const gid = parseOctalBytes(buffer, 116, 8);
|
|
@@ -476,7 +476,7 @@ const parseTarHeader = (buffer) => {
|
|
|
476
476
|
if (calculatedSum !== checksum) {
|
|
477
477
|
throw new Error(`Invalid checksum: expected ${checksum}, got ${calculatedSum}`);
|
|
478
478
|
}
|
|
479
|
-
let path = prefix ? `${prefix}/${
|
|
479
|
+
let path = prefix ? `${prefix}/${name2}` : name2;
|
|
480
480
|
if (path.endsWith("/")) {
|
|
481
481
|
path = path.slice(0, -1);
|
|
482
482
|
}
|
|
@@ -836,8 +836,8 @@ const parseInheritableFields = (inheritableFieldsOption) => {
|
|
|
836
836
|
}
|
|
837
837
|
return new Set(inheritableFieldsOption.split(",").map((field) => field.trim()).filter((field) => field.length > 0));
|
|
838
838
|
};
|
|
839
|
-
const showDumpHelp = (
|
|
840
|
-
|
|
839
|
+
const showDumpHelp = () => {
|
|
840
|
+
console.info(`Usage: screw-up dump [options] [directory]
|
|
841
841
|
|
|
842
842
|
Dump computed package.json as JSON
|
|
843
843
|
|
|
@@ -853,7 +853,7 @@ Options:
|
|
|
853
853
|
};
|
|
854
854
|
const dumpCommand = async (args, logger2) => {
|
|
855
855
|
if (args.options.help || args.options.h) {
|
|
856
|
-
showDumpHelp(
|
|
856
|
+
showDumpHelp();
|
|
857
857
|
return 1;
|
|
858
858
|
}
|
|
859
859
|
const directory = args.positional[0];
|
|
@@ -878,17 +878,17 @@ const dumpCommand = async (args, logger2) => {
|
|
|
878
878
|
if (computedPackageJson) {
|
|
879
879
|
logger2.info(JSON.stringify(computedPackageJson, null, 2));
|
|
880
880
|
} else {
|
|
881
|
-
logger2.error(`
|
|
881
|
+
logger2.error(`dump: Unable to read package.json from: ${targetDir}`);
|
|
882
882
|
return 1;
|
|
883
883
|
}
|
|
884
884
|
} catch (error) {
|
|
885
|
-
logger2.error(`
|
|
885
|
+
logger2.error(`dump: Failed to dump package.json: ${error}`);
|
|
886
886
|
return 1;
|
|
887
887
|
}
|
|
888
888
|
return 0;
|
|
889
889
|
};
|
|
890
|
-
const showPackHelp = (
|
|
891
|
-
|
|
890
|
+
const showPackHelp = () => {
|
|
891
|
+
console.info(`Usage: screw-up pack [options] [directory]
|
|
892
892
|
|
|
893
893
|
Pack the project into a tar archive
|
|
894
894
|
|
|
@@ -910,7 +910,7 @@ Options:
|
|
|
910
910
|
const packCommand = async (args, logger2) => {
|
|
911
911
|
var _a;
|
|
912
912
|
if (args.options.help || args.options.h) {
|
|
913
|
-
showPackHelp(
|
|
913
|
+
showPackHelp();
|
|
914
914
|
return 1;
|
|
915
915
|
}
|
|
916
916
|
const directory = args.positional[0];
|
|
@@ -927,7 +927,7 @@ const packCommand = async (args, logger2) => {
|
|
|
927
927
|
const readmeReplacementPath = readmeOption ? resolve(readmeOption) : void 0;
|
|
928
928
|
const inheritableFields = parseInheritableFields(inheritableFieldsOption);
|
|
929
929
|
if (verbose) {
|
|
930
|
-
logger2.info(`
|
|
930
|
+
logger2.info(`pack: Creating archive of ${targetDir}...`);
|
|
931
931
|
}
|
|
932
932
|
try {
|
|
933
933
|
const result = await packAssets(
|
|
@@ -943,22 +943,22 @@ const packCommand = async (args, logger2) => {
|
|
|
943
943
|
);
|
|
944
944
|
if (result) {
|
|
945
945
|
if (verbose) {
|
|
946
|
-
logger2.info(`
|
|
946
|
+
logger2.info(`pack: Archive created successfully: ${result.packageFileName}`);
|
|
947
947
|
} else {
|
|
948
948
|
logger2.info(result.packageFileName);
|
|
949
949
|
}
|
|
950
950
|
} else {
|
|
951
|
-
logger2.error(`
|
|
951
|
+
logger2.error(`pack: Unable to find any files to pack: ${targetDir}`);
|
|
952
952
|
return 1;
|
|
953
953
|
}
|
|
954
954
|
} catch (error) {
|
|
955
|
-
logger2.error(`
|
|
955
|
+
logger2.error(`pack: Failed to create archive: ${error}`);
|
|
956
956
|
return 1;
|
|
957
957
|
}
|
|
958
958
|
return 0;
|
|
959
959
|
};
|
|
960
|
-
const showPublishHelp = (
|
|
961
|
-
|
|
960
|
+
const showPublishHelp = () => {
|
|
961
|
+
console.info(`Usage: screw-up publish [options] [directory|package.tgz]
|
|
962
962
|
|
|
963
963
|
Publish the project
|
|
964
964
|
|
|
@@ -982,14 +982,14 @@ Examples:
|
|
|
982
982
|
};
|
|
983
983
|
const runNpmPublish = async (tarballPath, npmOptions, verbose, logger2) => {
|
|
984
984
|
if (verbose) {
|
|
985
|
-
logger2.info(`
|
|
985
|
+
logger2.info(`publish: Publishing ${tarballPath} to npm...`);
|
|
986
986
|
}
|
|
987
987
|
const publishArgs = ["publish", tarballPath, ...npmOptions];
|
|
988
988
|
if (process.env.SCREW_UP_TEST_MODE === "true") {
|
|
989
|
-
logger2.info(`
|
|
990
|
-
logger2.info(`
|
|
991
|
-
logger2.info(`
|
|
992
|
-
logger2.info(`
|
|
989
|
+
logger2.info(`TEST_MODE: Would execute: npm ${publishArgs.join(" ")}`);
|
|
990
|
+
logger2.info(`TEST_MODE: Tarball path: ${tarballPath}`);
|
|
991
|
+
logger2.info(`TEST_MODE: Options: ${npmOptions.join(" ")}`);
|
|
992
|
+
logger2.info(`publish: Successfully published ${tarballPath}`);
|
|
993
993
|
return 0;
|
|
994
994
|
}
|
|
995
995
|
const npmProcess = spawn("npm", publishArgs, { stdio: "inherit" });
|
|
@@ -997,11 +997,11 @@ const runNpmPublish = async (tarballPath, npmOptions, verbose, logger2) => {
|
|
|
997
997
|
npmProcess.on("close", (code) => {
|
|
998
998
|
if (code === 0) {
|
|
999
999
|
if (verbose) {
|
|
1000
|
-
logger2.info(`
|
|
1000
|
+
logger2.info(`publish: Successfully published ${tarballPath}`);
|
|
1001
1001
|
}
|
|
1002
1002
|
resolve2(code);
|
|
1003
1003
|
} else {
|
|
1004
|
-
logger2.error(`
|
|
1004
|
+
logger2.error(`publish: npm publish failed: ${tarballPath}`);
|
|
1005
1005
|
resolve2(code);
|
|
1006
1006
|
}
|
|
1007
1007
|
});
|
|
@@ -1011,7 +1011,7 @@ const runNpmPublish = async (tarballPath, npmOptions, verbose, logger2) => {
|
|
|
1011
1011
|
const publishCommand = async (args, logger2) => {
|
|
1012
1012
|
var _a;
|
|
1013
1013
|
if (args.options.help || args.options.h) {
|
|
1014
|
-
showPublishHelp(
|
|
1014
|
+
showPublishHelp();
|
|
1015
1015
|
return 1;
|
|
1016
1016
|
}
|
|
1017
1017
|
const path = args.positional[0];
|
|
@@ -1040,7 +1040,7 @@ const publishCommand = async (args, logger2) => {
|
|
|
1040
1040
|
const targetDir = process.cwd();
|
|
1041
1041
|
const outputDir = await mkdtemp(join(tmpdir(), "screw-up-publish-"));
|
|
1042
1042
|
if (verbose) {
|
|
1043
|
-
logger2.info(`
|
|
1043
|
+
logger2.info(`publish: Creating archive of ${targetDir}...`);
|
|
1044
1044
|
}
|
|
1045
1045
|
try {
|
|
1046
1046
|
const result = await packAssets(
|
|
@@ -1056,12 +1056,12 @@ const publishCommand = async (args, logger2) => {
|
|
|
1056
1056
|
);
|
|
1057
1057
|
if (result == null ? void 0 : result.metadata) {
|
|
1058
1058
|
if (verbose) {
|
|
1059
|
-
logger2.info(`
|
|
1059
|
+
logger2.info(`publish: Archive created successfully: ${result.packageFileName}`);
|
|
1060
1060
|
}
|
|
1061
1061
|
const archivePath = join(outputDir, result.packageFileName);
|
|
1062
1062
|
return await runNpmPublish(archivePath, npmOptions, verbose, logger2);
|
|
1063
1063
|
} else {
|
|
1064
|
-
logger2.error(`
|
|
1064
|
+
logger2.error(`publish: Unable to find any files to pack: ${targetDir}`);
|
|
1065
1065
|
return 1;
|
|
1066
1066
|
}
|
|
1067
1067
|
} finally {
|
|
@@ -1075,7 +1075,7 @@ const publishCommand = async (args, logger2) => {
|
|
|
1075
1075
|
const targetDir = resolve(path);
|
|
1076
1076
|
const outputDir = await mkdtemp(join(tmpdir(), "screw-up-publish-"));
|
|
1077
1077
|
if (verbose) {
|
|
1078
|
-
logger2.info(`
|
|
1078
|
+
logger2.info(`publish: Creating archive of ${targetDir}...`);
|
|
1079
1079
|
}
|
|
1080
1080
|
try {
|
|
1081
1081
|
const result = await packAssets(
|
|
@@ -1091,33 +1091,34 @@ const publishCommand = async (args, logger2) => {
|
|
|
1091
1091
|
);
|
|
1092
1092
|
if (result == null ? void 0 : result.metadata) {
|
|
1093
1093
|
if (verbose) {
|
|
1094
|
-
logger2.info(`
|
|
1094
|
+
logger2.info(`publish: Archive created successfully: ${result.packageFileName}`);
|
|
1095
1095
|
}
|
|
1096
1096
|
const archivePath = join(outputDir, result.packageFileName);
|
|
1097
1097
|
return await runNpmPublish(archivePath, npmOptions, verbose, logger2);
|
|
1098
1098
|
} else {
|
|
1099
|
-
logger2.error(`
|
|
1099
|
+
logger2.error(`publish: Unable to find any files to pack: ${targetDir}`);
|
|
1100
1100
|
return 1;
|
|
1101
1101
|
}
|
|
1102
1102
|
} finally {
|
|
1103
1103
|
await rm(outputDir, { recursive: true, force: true });
|
|
1104
1104
|
}
|
|
1105
1105
|
} else {
|
|
1106
|
-
logger2.error(`
|
|
1106
|
+
logger2.error(`publish: Invalid path - must be a directory or .tgz/.tar.gz file: ${path}`);
|
|
1107
1107
|
return 1;
|
|
1108
1108
|
}
|
|
1109
1109
|
} else {
|
|
1110
|
-
logger2.error(`
|
|
1110
|
+
logger2.error(`publish: Path does not exist: ${path}`);
|
|
1111
1111
|
return 1;
|
|
1112
1112
|
}
|
|
1113
1113
|
} catch (error) {
|
|
1114
|
-
logger2.error(`
|
|
1114
|
+
logger2.error(`publish: Failed to publish: ${error}`);
|
|
1115
1115
|
return 1;
|
|
1116
1116
|
}
|
|
1117
1117
|
};
|
|
1118
|
-
const showHelp = async (
|
|
1119
|
-
const { author, license, repository_url, version } = await import("./packageMetadata-
|
|
1120
|
-
|
|
1118
|
+
const showHelp = async () => {
|
|
1119
|
+
const { author, license, repository_url, version, git_commit_hash } = await import("./packageMetadata-DOzhlPbz.js").then((n) => n.p);
|
|
1120
|
+
console.info(`screw-up [${version}-${git_commit_hash}]
|
|
1121
|
+
Easy package metadata inserter CLI
|
|
1121
1122
|
Copyright (c) ${author}
|
|
1122
1123
|
Repository: ${repository_url}
|
|
1123
1124
|
License: ${license}
|
|
@@ -1148,7 +1149,7 @@ const argOptionMap = /* @__PURE__ */ new Map([
|
|
|
1148
1149
|
const cliMain = async (args, logger2) => {
|
|
1149
1150
|
const parsedArgs = parseArgs(args, argOptionMap);
|
|
1150
1151
|
if (!parsedArgs.command && (parsedArgs.options.help || parsedArgs.options.h)) {
|
|
1151
|
-
await showHelp(
|
|
1152
|
+
await showHelp();
|
|
1152
1153
|
return 1;
|
|
1153
1154
|
}
|
|
1154
1155
|
switch (parsedArgs.command) {
|
|
@@ -1168,7 +1169,8 @@ const cliMain = async (args, logger2) => {
|
|
|
1168
1169
|
return 1;
|
|
1169
1170
|
}
|
|
1170
1171
|
};
|
|
1171
|
-
const
|
|
1172
|
+
const loggerPrefix = `${name}-cli`;
|
|
1173
|
+
const logger = createConsoleLogger(loggerPrefix);
|
|
1172
1174
|
cliMain(
|
|
1173
1175
|
process.argv.slice(2),
|
|
1174
1176
|
// Remove 'node' and script path
|