@depup/oclif 4.22.92-depup.1
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/LICENSE +21 -0
- package/README.md +44 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +7 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +7 -0
- package/changes.json +62 -0
- package/lib/aws.d.ts +22 -0
- package/lib/aws.js +146 -0
- package/lib/commands/generate/command.d.ts +12 -0
- package/lib/commands/generate/command.js +44 -0
- package/lib/commands/generate/hook.d.ts +12 -0
- package/lib/commands/generate/hook.js +87 -0
- package/lib/commands/generate.d.ts +67 -0
- package/lib/commands/generate.js +269 -0
- package/lib/commands/init.d.ts +39 -0
- package/lib/commands/init.js +165 -0
- package/lib/commands/lock.d.ts +4 -0
- package/lib/commands/lock.js +70 -0
- package/lib/commands/manifest.d.ts +13 -0
- package/lib/commands/manifest.js +156 -0
- package/lib/commands/pack/deb.d.ts +13 -0
- package/lib/commands/pack/deb.js +194 -0
- package/lib/commands/pack/macos.d.ts +14 -0
- package/lib/commands/pack/macos.js +273 -0
- package/lib/commands/pack/tarballs.d.ts +15 -0
- package/lib/commands/pack/tarballs.js +77 -0
- package/lib/commands/pack/win.d.ts +16 -0
- package/lib/commands/pack/win.js +398 -0
- package/lib/commands/promote.d.ts +20 -0
- package/lib/commands/promote.js +305 -0
- package/lib/commands/readme.d.ts +19 -0
- package/lib/commands/readme.js +143 -0
- package/lib/commands/upload/deb.d.ts +10 -0
- package/lib/commands/upload/deb.js +113 -0
- package/lib/commands/upload/macos.d.ts +11 -0
- package/lib/commands/upload/macos.js +92 -0
- package/lib/commands/upload/tarballs.d.ts +12 -0
- package/lib/commands/upload/tarballs.js +135 -0
- package/lib/commands/upload/win.d.ts +11 -0
- package/lib/commands/upload/win.js +97 -0
- package/lib/generator.d.ts +57 -0
- package/lib/generator.js +184 -0
- package/lib/help-compatibility.d.ts +11 -0
- package/lib/help-compatibility.js +22 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -0
- package/lib/log.d.ts +2 -0
- package/lib/log.js +13 -0
- package/lib/readme-generator.d.ts +38 -0
- package/lib/readme-generator.js +305 -0
- package/lib/tarballs/bin.d.ts +7 -0
- package/lib/tarballs/bin.js +126 -0
- package/lib/tarballs/build.d.ts +10 -0
- package/lib/tarballs/build.js +250 -0
- package/lib/tarballs/config.d.ts +45 -0
- package/lib/tarballs/config.js +132 -0
- package/lib/tarballs/index.d.ts +4 -0
- package/lib/tarballs/index.js +20 -0
- package/lib/tarballs/node.d.ts +10 -0
- package/lib/tarballs/node.js +78 -0
- package/lib/upload-util.d.ts +17 -0
- package/lib/upload-util.js +56 -0
- package/lib/util.d.ts +18 -0
- package/lib/util.js +160 -0
- package/lib/version-indexes.d.ts +9 -0
- package/lib/version-indexes.js +119 -0
- package/oclif.manifest.json +1199 -0
- package/package.json +217 -0
- package/templates/cli/commonjs/.mocharc.json.ejs +11 -0
- package/templates/cli/commonjs/.vscode/launch.json.ejs +20 -0
- package/templates/cli/commonjs/bin/dev.cmd.ejs +3 -0
- package/templates/cli/commonjs/bin/dev.js.ejs +7 -0
- package/templates/cli/commonjs/bin/run.cmd.ejs +3 -0
- package/templates/cli/commonjs/bin/run.js.ejs +7 -0
- package/templates/cli/commonjs/eslint.config.mjs.ejs +19 -0
- package/templates/cli/commonjs/tsconfig.json.ejs +11 -0
- package/templates/cli/esm/.mocharc.json.ejs +15 -0
- package/templates/cli/esm/.vscode/launch.json.ejs +22 -0
- package/templates/cli/esm/bin/dev.cmd.ejs +3 -0
- package/templates/cli/esm/bin/dev.js.ejs +5 -0
- package/templates/cli/esm/bin/run.cmd.ejs +3 -0
- package/templates/cli/esm/bin/run.js.ejs +5 -0
- package/templates/cli/esm/eslint.config.mjs.ejs +9 -0
- package/templates/cli/esm/tsconfig.json.ejs +15 -0
- package/templates/cli/shared/.github/workflows/onPushToMain.yml.ejs +56 -0
- package/templates/cli/shared/.github/workflows/onRelease.yml.ejs +21 -0
- package/templates/cli/shared/.github/workflows/test.yml.ejs +23 -0
- package/templates/cli/shared/.gitignore.ejs +27 -0
- package/templates/cli/shared/.prettierrc.json.ejs +1 -0
- package/templates/cli/shared/README.md.ejs +396 -0
- package/templates/cli/shared/package.json.ejs +73 -0
- package/templates/cli/shared/src/commands/hello/index.ts.ejs +22 -0
- package/templates/cli/shared/src/commands/hello/world.ts.ejs +16 -0
- package/templates/cli/shared/src/index.ts.ejs +1 -0
- package/templates/cli/shared/test/commands/hello/index.test.ts.ejs +9 -0
- package/templates/cli/shared/test/commands/hello/world.test.ts.ejs +9 -0
- package/templates/cli/shared/test/tsconfig.json.ejs +9 -0
- package/templates/src/command.ts.ejs +27 -0
- package/templates/src/hook.ts.ejs +7 -0
- package/templates/src/init/dev.cmd.ejs +12 -0
- package/templates/src/init/dev.js.ejs +17 -0
- package/templates/src/init/run.cmd.ejs +3 -0
- package/templates/src/init/run.js.ejs +17 -0
- package/templates/test/command.test.ts.ejs +14 -0
- package/templates/test/hook.test.ts.ejs +9 -0
package/lib/util.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.hash = exports.prettifyPaths = exports.sortVersionsObjectByKeysDesc = void 0;
|
|
37
|
+
exports.castArray = castArray;
|
|
38
|
+
exports.uniqBy = uniqBy;
|
|
39
|
+
exports.compact = compact;
|
|
40
|
+
exports.uniq = uniq;
|
|
41
|
+
exports.sortBy = sortBy;
|
|
42
|
+
exports.checkFor7Zip = checkFor7Zip;
|
|
43
|
+
exports.isEmpty = isEmpty;
|
|
44
|
+
exports.validateBin = validateBin;
|
|
45
|
+
exports.isS3Compatible = isS3Compatible;
|
|
46
|
+
exports.getS3ChecksumConfig = getS3ChecksumConfig;
|
|
47
|
+
const core_1 = require("@oclif/core");
|
|
48
|
+
const node_child_process_1 = require("node:child_process");
|
|
49
|
+
const crypto = __importStar(require("node:crypto"));
|
|
50
|
+
const node_fs_1 = require("node:fs");
|
|
51
|
+
const os = __importStar(require("node:os"));
|
|
52
|
+
const node_util_1 = require("node:util");
|
|
53
|
+
const log_1 = require("./log");
|
|
54
|
+
const exec = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
55
|
+
function castArray(input) {
|
|
56
|
+
if (input === undefined)
|
|
57
|
+
return [];
|
|
58
|
+
return Array.isArray(input) ? input : [input];
|
|
59
|
+
}
|
|
60
|
+
function uniqBy(arr, fn) {
|
|
61
|
+
return arr.filter((a, i) => {
|
|
62
|
+
const aVal = fn(a);
|
|
63
|
+
return !arr.some((b, j) => j > i && fn(b) === aVal);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function compact(a) {
|
|
67
|
+
// eslint-disable-next-line unicorn/prefer-native-coercion-functions
|
|
68
|
+
return a.filter((a) => Boolean(a));
|
|
69
|
+
}
|
|
70
|
+
function uniq(arr) {
|
|
71
|
+
return [...new Set(arr)];
|
|
72
|
+
}
|
|
73
|
+
function compare(a, b) {
|
|
74
|
+
a = a === undefined ? 0 : a;
|
|
75
|
+
b = b === undefined ? 0 : b;
|
|
76
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
77
|
+
if (a.length === 0 && b.length === 0)
|
|
78
|
+
return 0;
|
|
79
|
+
const diff = compare(a[0], b[0]);
|
|
80
|
+
if (diff !== 0)
|
|
81
|
+
return diff;
|
|
82
|
+
return compare(a.slice(1), b.slice(1));
|
|
83
|
+
}
|
|
84
|
+
if (a < b)
|
|
85
|
+
return -1;
|
|
86
|
+
if (a > b)
|
|
87
|
+
return 1;
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
function sortBy(arr, fn) {
|
|
91
|
+
return arr.sort((a, b) => compare(fn(a), fn(b)));
|
|
92
|
+
}
|
|
93
|
+
const sortVersionsObjectByKeysDesc = (input) => {
|
|
94
|
+
const keys = Reflect.ownKeys(input).sort((a, b) => {
|
|
95
|
+
const splitA = a.split('.').map((part) => Number.parseInt(part, 10));
|
|
96
|
+
const splitB = b.split('.').map((part) => Number.parseInt(part, 10));
|
|
97
|
+
// sort by major
|
|
98
|
+
if (splitA[0] < splitB[0])
|
|
99
|
+
return 1;
|
|
100
|
+
if (splitA[0] > splitB[0])
|
|
101
|
+
return -1;
|
|
102
|
+
// sort by minor
|
|
103
|
+
if (splitA[1] < splitB[1])
|
|
104
|
+
return 1;
|
|
105
|
+
if (splitA[1] > splitB[1])
|
|
106
|
+
return -1;
|
|
107
|
+
// sort by patch
|
|
108
|
+
if (splitA[2] < splitB[2])
|
|
109
|
+
return 1;
|
|
110
|
+
if (splitA[2] > splitB[2])
|
|
111
|
+
return -1;
|
|
112
|
+
return 0;
|
|
113
|
+
});
|
|
114
|
+
const result = {};
|
|
115
|
+
for (const key of keys) {
|
|
116
|
+
result[key] = input[key];
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
exports.sortVersionsObjectByKeysDesc = sortVersionsObjectByKeysDesc;
|
|
121
|
+
const homeRegexp = new RegExp(`\\B${os.homedir().replace('/', String.raw `\/`)}`, 'g');
|
|
122
|
+
const curRegexp = new RegExp(`\\B${process.cwd()}`, 'g');
|
|
123
|
+
const prettifyPaths = (input) => (input ?? '').toString().replace(curRegexp, '.').replace(homeRegexp, '~');
|
|
124
|
+
exports.prettifyPaths = prettifyPaths;
|
|
125
|
+
const hash = async (algo, fp) => {
|
|
126
|
+
const f = Array.isArray(fp) ? fp.join('') : fp;
|
|
127
|
+
(0, log_1.log)('hash', algo, f);
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
const hashInProgress = crypto.createHash(algo);
|
|
130
|
+
const stream = (0, node_fs_1.createReadStream)(f);
|
|
131
|
+
stream.on('error', (err) => reject(err));
|
|
132
|
+
stream.on('data', (chunk) => hashInProgress.update(chunk));
|
|
133
|
+
stream.on('end', () => resolve(hashInProgress.digest('hex')));
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
exports.hash = hash;
|
|
137
|
+
async function checkFor7Zip() {
|
|
138
|
+
try {
|
|
139
|
+
await exec('7z');
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
const { code } = error;
|
|
143
|
+
if (code === 127)
|
|
144
|
+
core_1.Errors.error('install 7-zip to package windows tarball');
|
|
145
|
+
else
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function isEmpty(obj) {
|
|
150
|
+
return Object.keys(obj).length === 0;
|
|
151
|
+
}
|
|
152
|
+
function validateBin(bin) {
|
|
153
|
+
return /^[\w-]+$/.test(bin);
|
|
154
|
+
}
|
|
155
|
+
function isS3Compatible(endpoint) {
|
|
156
|
+
return Boolean(endpoint && !endpoint.includes('amazonaws.com'));
|
|
157
|
+
}
|
|
158
|
+
function getS3ChecksumConfig(endpoint, envValue) {
|
|
159
|
+
return envValue || (isS3Compatible(endpoint) ? 'WHEN_REQUIRED' : undefined);
|
|
160
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.appendToIndex = void 0;
|
|
40
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
41
|
+
const fs = __importStar(require("fs-extra"));
|
|
42
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
43
|
+
const aws_1 = __importDefault(require("./aws"));
|
|
44
|
+
const log_1 = require("./log");
|
|
45
|
+
const debug = log_1.debug.new('version-indexes');
|
|
46
|
+
const sortVersionsObjectByKeysDesc = (input, keyLimit) => {
|
|
47
|
+
const keys = Reflect.ownKeys(input).sort((a, b) => {
|
|
48
|
+
const splitA = a.split('.').map((part) => Number.parseInt(part, 10));
|
|
49
|
+
const splitB = b.split('.').map((part) => Number.parseInt(part, 10));
|
|
50
|
+
// sort by major
|
|
51
|
+
if (splitA[0] < splitB[0])
|
|
52
|
+
return 1;
|
|
53
|
+
if (splitA[0] > splitB[0])
|
|
54
|
+
return -1;
|
|
55
|
+
// sort by minor
|
|
56
|
+
if (splitA[1] < splitB[1])
|
|
57
|
+
return 1;
|
|
58
|
+
if (splitA[1] > splitB[1])
|
|
59
|
+
return -1;
|
|
60
|
+
// sort by patch
|
|
61
|
+
if (splitA[2] < splitB[2])
|
|
62
|
+
return 1;
|
|
63
|
+
if (splitA[2] > splitB[2])
|
|
64
|
+
return -1;
|
|
65
|
+
return 0;
|
|
66
|
+
}).slice(0, keyLimit); // undefined keyLimit returns the entire array
|
|
67
|
+
const result = {};
|
|
68
|
+
for (const key of keys) {
|
|
69
|
+
result[key] = input[key];
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
};
|
|
73
|
+
// appends to an existing file (or writes a new one) with the versions in descending order, with an optional limit from the pjson file
|
|
74
|
+
const appendToIndex = async (input) => {
|
|
75
|
+
const { filename, maxAge, originalUrl, s3Config, version } = input;
|
|
76
|
+
// these checks are both nice for users AND helpful for TS
|
|
77
|
+
if (!s3Config.bucket)
|
|
78
|
+
throw new Error('[package.json].oclif.s3.bucket is required for indexes');
|
|
79
|
+
if (!s3Config.host)
|
|
80
|
+
throw new Error('[package.json].oclif.s3.host is required for indexes');
|
|
81
|
+
// json-friendly filenames like sfdx-linux-x64-tar-gz
|
|
82
|
+
const jsonFileName = `${filename.replaceAll('.', '-')}.json`;
|
|
83
|
+
// folder is optional, but honored if present
|
|
84
|
+
const key = node_path_1.default.posix.join(s3Config.folder ?? '', 'versions', jsonFileName);
|
|
85
|
+
// retrieve existing index file
|
|
86
|
+
let existing = {};
|
|
87
|
+
try {
|
|
88
|
+
const { Body } = await aws_1.default.s3.getObject({
|
|
89
|
+
Bucket: s3Config.bucket,
|
|
90
|
+
Key: key,
|
|
91
|
+
});
|
|
92
|
+
// @ts-expect-error because StreamingBlobTypes doesn't have transformToString
|
|
93
|
+
// but it's expected to be there according to the docs
|
|
94
|
+
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/TypeAlias/StreamingBlobPayloadOutputTypes/
|
|
95
|
+
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/Interface/SdkStreamMixin/
|
|
96
|
+
existing = JSON.parse(await Body?.transformToString());
|
|
97
|
+
debug('appending to existing index file');
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
debug(`error on ${key}`, error);
|
|
101
|
+
}
|
|
102
|
+
// appends new version from this promotion if not already present (idempotent)
|
|
103
|
+
await fs.writeJSON(jsonFileName, sortVersionsObjectByKeysDesc({
|
|
104
|
+
...existing,
|
|
105
|
+
[version]: originalUrl.replace(s3Config.bucket, s3Config.host),
|
|
106
|
+
}, s3Config.indexVersionLimit), { spaces: 2 });
|
|
107
|
+
// put the file back in the same place
|
|
108
|
+
await aws_1.default.s3.uploadFile(jsonFileName, {
|
|
109
|
+
ACL: s3Config.acl ?? client_s3_1.ObjectCannedACL.public_read,
|
|
110
|
+
Bucket: s3Config.bucket,
|
|
111
|
+
CacheControl: maxAge,
|
|
112
|
+
Key: key,
|
|
113
|
+
}, {
|
|
114
|
+
dryRun: input.dryRun,
|
|
115
|
+
});
|
|
116
|
+
// cleans up local fs
|
|
117
|
+
await fs.remove(jsonFileName);
|
|
118
|
+
};
|
|
119
|
+
exports.appendToIndex = appendToIndex;
|