@capgo/cli 4.10.27 → 4.10.29
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/.github/workflows/check_posix_paths.yml +31 -2
- package/CHANGELOG.md +10 -0
- package/bun.lockb +0 -0
- package/dist/index.js +452 -50
- package/package.json +4 -2
- package/src/init.ts +105 -12
|
@@ -37,5 +37,34 @@ jobs:
|
|
|
37
37
|
id: create_zip
|
|
38
38
|
run: node ./dist/index.js bundle zip --path test/test_upload -n build.zip
|
|
39
39
|
|
|
40
|
-
- name:
|
|
41
|
-
|
|
40
|
+
- name: Upload build.zip artifact
|
|
41
|
+
uses: actions/upload-artifact@v2
|
|
42
|
+
with:
|
|
43
|
+
name: build-zip
|
|
44
|
+
path: build.zip
|
|
45
|
+
|
|
46
|
+
check-posix-paths-unix:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
|
|
49
|
+
steps:
|
|
50
|
+
- name: Download build.zip artifact
|
|
51
|
+
uses: actions/download-artifact@v2
|
|
52
|
+
with:
|
|
53
|
+
name: build-zip
|
|
54
|
+
|
|
55
|
+
- name: Verify POSIX paths
|
|
56
|
+
run: |
|
|
57
|
+
unzip build.zip -d extracted
|
|
58
|
+
error_found=false
|
|
59
|
+
find extracted -type f | while read -r file; do
|
|
60
|
+
if [[ "$file" =~ "\\" ]]; then
|
|
61
|
+
echo "Non-POSIX path detected: $file"
|
|
62
|
+
error_found=true
|
|
63
|
+
fi
|
|
64
|
+
done
|
|
65
|
+
if [ "$error_found" = true ]; then
|
|
66
|
+
echo "Non-POSIX paths detected in the zip file"
|
|
67
|
+
exit 1
|
|
68
|
+
else
|
|
69
|
+
echo "All paths are POSIX compliant."
|
|
70
|
+
fi
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.10.29](https://github.com/Cap-go/CLI/compare/v4.10.28...v4.10.29) (2024-06-21)
|
|
6
|
+
|
|
7
|
+
### [4.10.28](https://github.com/Cap-go/CLI/compare/v4.10.27...v4.10.28) (2024-06-20)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* lockfile issue ([a63b4eb](https://github.com/Cap-go/CLI/commit/a63b4eb53bf8959e3c839aa6297f5d181d2da576))
|
|
13
|
+
* try another way to test posix ([9e7574d](https://github.com/Cap-go/CLI/commit/9e7574d24e54339b8f41de7958d5562682466088))
|
|
14
|
+
|
|
5
15
|
### [4.10.27](https://github.com/Cap-go/CLI/compare/v4.10.26...v4.10.27) (2024-06-20)
|
|
6
16
|
|
|
7
17
|
|
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -7196,13 +7196,13 @@ var require_kleur = __commonJS({
|
|
|
7196
7196
|
bgWhite: init(47, 49)
|
|
7197
7197
|
};
|
|
7198
7198
|
function run(arr, str) {
|
|
7199
|
-
let i = 0,
|
|
7199
|
+
let i = 0, tmp2, beg = "", end = "";
|
|
7200
7200
|
for (; i < arr.length; i++) {
|
|
7201
|
-
|
|
7202
|
-
beg +=
|
|
7203
|
-
end +=
|
|
7204
|
-
if (!!~str.indexOf(
|
|
7205
|
-
str = str.replace(
|
|
7201
|
+
tmp2 = arr[i];
|
|
7202
|
+
beg += tmp2.open;
|
|
7203
|
+
end += tmp2.close;
|
|
7204
|
+
if (!!~str.indexOf(tmp2.close)) {
|
|
7205
|
+
str = str.replace(tmp2.rgx, tmp2.close + tmp2.open);
|
|
7206
7206
|
}
|
|
7207
7207
|
}
|
|
7208
7208
|
return beg + str + end;
|
|
@@ -9860,13 +9860,13 @@ var require_kleur2 = __commonJS({
|
|
|
9860
9860
|
bgWhite: init(47, 49)
|
|
9861
9861
|
};
|
|
9862
9862
|
function run(arr, str) {
|
|
9863
|
-
let i = 0,
|
|
9863
|
+
let i = 0, tmp2, beg = "", end = "";
|
|
9864
9864
|
for (; i < arr.length; i++) {
|
|
9865
|
-
|
|
9866
|
-
beg +=
|
|
9867
|
-
end +=
|
|
9868
|
-
if (str.includes(
|
|
9869
|
-
str = str.replace(
|
|
9865
|
+
tmp2 = arr[i];
|
|
9866
|
+
beg += tmp2.open;
|
|
9867
|
+
end += tmp2.close;
|
|
9868
|
+
if (str.includes(tmp2.close)) {
|
|
9869
|
+
str = str.replace(tmp2.rgx, tmp2.close + tmp2.open);
|
|
9870
9870
|
}
|
|
9871
9871
|
}
|
|
9872
9872
|
return beg + str + end;
|
|
@@ -35169,9 +35169,9 @@ var require_utf16 = __commonJS({
|
|
|
35169
35169
|
Utf16BEEncoder.prototype.write = function(str) {
|
|
35170
35170
|
var buf = Buffer4.from(str, "ucs2");
|
|
35171
35171
|
for (var i = 0; i < buf.length; i += 2) {
|
|
35172
|
-
var
|
|
35172
|
+
var tmp2 = buf[i];
|
|
35173
35173
|
buf[i] = buf[i + 1];
|
|
35174
|
-
buf[i + 1] =
|
|
35174
|
+
buf[i + 1] = tmp2;
|
|
35175
35175
|
}
|
|
35176
35176
|
return buf;
|
|
35177
35177
|
};
|
|
@@ -52933,7 +52933,7 @@ var require_loader = __commonJS({
|
|
|
52933
52933
|
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
52934
52934
|
}
|
|
52935
52935
|
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
52936
|
-
var captureStart, captureEnd, hexLength, hexResult,
|
|
52936
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp2, ch;
|
|
52937
52937
|
ch = state.input.charCodeAt(state.position);
|
|
52938
52938
|
if (ch !== 34) {
|
|
52939
52939
|
return false;
|
|
@@ -52955,13 +52955,13 @@ var require_loader = __commonJS({
|
|
|
52955
52955
|
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
52956
52956
|
state.result += simpleEscapeMap[ch];
|
|
52957
52957
|
state.position++;
|
|
52958
|
-
} else if ((
|
|
52959
|
-
hexLength =
|
|
52958
|
+
} else if ((tmp2 = escapedHexLen(ch)) > 0) {
|
|
52959
|
+
hexLength = tmp2;
|
|
52960
52960
|
hexResult = 0;
|
|
52961
52961
|
for (; hexLength > 0; hexLength--) {
|
|
52962
52962
|
ch = state.input.charCodeAt(++state.position);
|
|
52963
|
-
if ((
|
|
52964
|
-
hexResult = (hexResult << 4) +
|
|
52963
|
+
if ((tmp2 = fromHexCode(ch)) >= 0) {
|
|
52964
|
+
hexResult = (hexResult << 4) + tmp2;
|
|
52965
52965
|
} else {
|
|
52966
52966
|
throwError(state, "expected hexadecimal character");
|
|
52967
52967
|
}
|
|
@@ -53058,7 +53058,7 @@ var require_loader = __commonJS({
|
|
|
53058
53058
|
throwError(state, "unexpected end of the stream within a flow collection");
|
|
53059
53059
|
}
|
|
53060
53060
|
function readBlockScalar(state, nodeIndent) {
|
|
53061
|
-
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false,
|
|
53061
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp2, ch;
|
|
53062
53062
|
ch = state.input.charCodeAt(state.position);
|
|
53063
53063
|
if (ch === 124) {
|
|
53064
53064
|
folding = false;
|
|
@@ -53077,11 +53077,11 @@ var require_loader = __commonJS({
|
|
|
53077
53077
|
} else {
|
|
53078
53078
|
throwError(state, "repeat of a chomping mode identifier");
|
|
53079
53079
|
}
|
|
53080
|
-
} else if ((
|
|
53081
|
-
if (
|
|
53080
|
+
} else if ((tmp2 = fromDecimalCode(ch)) >= 0) {
|
|
53081
|
+
if (tmp2 === 0) {
|
|
53082
53082
|
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
53083
53083
|
} else if (!detectedIndent) {
|
|
53084
|
-
textIndent = nodeIndent +
|
|
53084
|
+
textIndent = nodeIndent + tmp2 - 1;
|
|
53085
53085
|
detectedIndent = true;
|
|
53086
53086
|
} else {
|
|
53087
53087
|
throwError(state, "repeat of an indentation width identifier");
|
|
@@ -57788,12 +57788,12 @@ var require_deflater = __commonJS({
|
|
|
57788
57788
|
return zlib.deflateRawSync(inbuf, opts);
|
|
57789
57789
|
},
|
|
57790
57790
|
deflateAsync: function(callback) {
|
|
57791
|
-
var
|
|
57792
|
-
|
|
57791
|
+
var tmp2 = zlib.createDeflateRaw(opts), parts = [], total = 0;
|
|
57792
|
+
tmp2.on("data", function(data) {
|
|
57793
57793
|
parts.push(data);
|
|
57794
57794
|
total += data.length;
|
|
57795
57795
|
});
|
|
57796
|
-
|
|
57796
|
+
tmp2.on("end", function() {
|
|
57797
57797
|
var buf = Buffer.alloc(total), written = 0;
|
|
57798
57798
|
buf.fill(0);
|
|
57799
57799
|
for (var i = 0; i < parts.length; i++) {
|
|
@@ -57803,7 +57803,7 @@ var require_deflater = __commonJS({
|
|
|
57803
57803
|
}
|
|
57804
57804
|
callback && callback(buf);
|
|
57805
57805
|
});
|
|
57806
|
-
|
|
57806
|
+
tmp2.end(inbuf);
|
|
57807
57807
|
}
|
|
57808
57808
|
};
|
|
57809
57809
|
};
|
|
@@ -57822,12 +57822,12 @@ var require_inflater = __commonJS({
|
|
|
57822
57822
|
return zlib.inflateRawSync(inbuf, option);
|
|
57823
57823
|
},
|
|
57824
57824
|
inflateAsync: function(callback) {
|
|
57825
|
-
var
|
|
57826
|
-
|
|
57825
|
+
var tmp2 = zlib.createInflateRaw(option), parts = [], total = 0;
|
|
57826
|
+
tmp2.on("data", function(data) {
|
|
57827
57827
|
parts.push(data);
|
|
57828
57828
|
total += data.length;
|
|
57829
57829
|
});
|
|
57830
|
-
|
|
57830
|
+
tmp2.on("end", function() {
|
|
57831
57831
|
var buf = Buffer.alloc(total), written = 0;
|
|
57832
57832
|
buf.fill(0);
|
|
57833
57833
|
for (var i = 0; i < parts.length; i++) {
|
|
@@ -57837,7 +57837,7 @@ var require_inflater = __commonJS({
|
|
|
57837
57837
|
}
|
|
57838
57838
|
callback && callback(buf);
|
|
57839
57839
|
});
|
|
57840
|
-
|
|
57840
|
+
tmp2.end(inbuf);
|
|
57841
57841
|
}
|
|
57842
57842
|
};
|
|
57843
57843
|
};
|
|
@@ -58282,10 +58282,10 @@ var require_zipFile = __commonJS({
|
|
|
58282
58282
|
const totalEntries = mainHeader.diskEntries;
|
|
58283
58283
|
let index = mainHeader.offset;
|
|
58284
58284
|
for (let i = 0; i < totalEntries; i++) {
|
|
58285
|
-
let
|
|
58285
|
+
let tmp2 = index;
|
|
58286
58286
|
const entry = new ZipEntry(inBuffer);
|
|
58287
|
-
entry.header = inBuffer.slice(
|
|
58288
|
-
entry.entryName = inBuffer.slice(
|
|
58287
|
+
entry.header = inBuffer.slice(tmp2, tmp2 += Utils.Constants.CENHDR);
|
|
58288
|
+
entry.entryName = inBuffer.slice(tmp2, tmp2 += entry.header.fileNameLength);
|
|
58289
58289
|
index += entry.header.centralHeaderSize;
|
|
58290
58290
|
callback(entry);
|
|
58291
58291
|
}
|
|
@@ -58299,13 +58299,13 @@ var require_zipFile = __commonJS({
|
|
|
58299
58299
|
entryList = new Array(mainHeader.diskEntries);
|
|
58300
58300
|
var index = mainHeader.offset;
|
|
58301
58301
|
for (var i = 0; i < entryList.length; i++) {
|
|
58302
|
-
var
|
|
58303
|
-
entry.header = inBuffer.slice(
|
|
58304
|
-
entry.entryName = inBuffer.slice(
|
|
58302
|
+
var tmp2 = index, entry = new ZipEntry(inBuffer);
|
|
58303
|
+
entry.header = inBuffer.slice(tmp2, tmp2 += Utils.Constants.CENHDR);
|
|
58304
|
+
entry.entryName = inBuffer.slice(tmp2, tmp2 += entry.header.fileNameLength);
|
|
58305
58305
|
if (entry.header.extraLength) {
|
|
58306
|
-
entry.extra = inBuffer.slice(
|
|
58306
|
+
entry.extra = inBuffer.slice(tmp2, tmp2 += entry.header.extraLength);
|
|
58307
58307
|
}
|
|
58308
|
-
if (entry.header.commentLength) entry.comment = inBuffer.slice(
|
|
58308
|
+
if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp2, tmp2 + entry.header.commentLength);
|
|
58309
58309
|
index += entry.header.centralHeaderSize;
|
|
58310
58310
|
entryList[i] = entry;
|
|
58311
58311
|
entryTable[entry.entryName] = entry;
|
|
@@ -75419,6 +75419,320 @@ var require_semver6 = __commonJS({
|
|
|
75419
75419
|
}
|
|
75420
75420
|
});
|
|
75421
75421
|
|
|
75422
|
+
// node_modules/tmp/lib/tmp.js
|
|
75423
|
+
var require_tmp = __commonJS({
|
|
75424
|
+
"node_modules/tmp/lib/tmp.js"(exports2, module2) {
|
|
75425
|
+
var fs6 = require("fs");
|
|
75426
|
+
var os4 = require("os");
|
|
75427
|
+
var path3 = require("path");
|
|
75428
|
+
var crypto6 = require("crypto");
|
|
75429
|
+
var _c = { fs: fs6.constants, os: os4.constants };
|
|
75430
|
+
var RANDOM_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
75431
|
+
var TEMPLATE_PATTERN = /XXXXXX/;
|
|
75432
|
+
var DEFAULT_TRIES = 3;
|
|
75433
|
+
var CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR);
|
|
75434
|
+
var IS_WIN32 = os4.platform() === "win32";
|
|
75435
|
+
var EBADF = _c.EBADF || _c.os.errno.EBADF;
|
|
75436
|
+
var ENOENT = _c.ENOENT || _c.os.errno.ENOENT;
|
|
75437
|
+
var DIR_MODE = 448;
|
|
75438
|
+
var FILE_MODE = 384;
|
|
75439
|
+
var EXIT = "exit";
|
|
75440
|
+
var _removeObjects = [];
|
|
75441
|
+
var FN_RMDIR_SYNC = fs6.rmdirSync.bind(fs6);
|
|
75442
|
+
var _gracefulCleanup = false;
|
|
75443
|
+
function rimraf(dirPath, callback) {
|
|
75444
|
+
return fs6.rm(dirPath, { recursive: true }, callback);
|
|
75445
|
+
}
|
|
75446
|
+
function FN_RIMRAF_SYNC(dirPath) {
|
|
75447
|
+
return fs6.rmSync(dirPath, { recursive: true });
|
|
75448
|
+
}
|
|
75449
|
+
function tmpName(options, callback) {
|
|
75450
|
+
const args = _parseArguments(options, callback), opts = args[0], cb = args[1];
|
|
75451
|
+
try {
|
|
75452
|
+
_assertAndSanitizeOptions(opts);
|
|
75453
|
+
} catch (err) {
|
|
75454
|
+
return cb(err);
|
|
75455
|
+
}
|
|
75456
|
+
let tries = opts.tries;
|
|
75457
|
+
(function _getUniqueName() {
|
|
75458
|
+
try {
|
|
75459
|
+
const name = _generateTmpName(opts);
|
|
75460
|
+
fs6.stat(name, function(err) {
|
|
75461
|
+
if (!err) {
|
|
75462
|
+
if (tries-- > 0) return _getUniqueName();
|
|
75463
|
+
return cb(new Error("Could not get a unique tmp filename, max tries reached " + name));
|
|
75464
|
+
}
|
|
75465
|
+
cb(null, name);
|
|
75466
|
+
});
|
|
75467
|
+
} catch (err) {
|
|
75468
|
+
cb(err);
|
|
75469
|
+
}
|
|
75470
|
+
})();
|
|
75471
|
+
}
|
|
75472
|
+
function tmpNameSync(options) {
|
|
75473
|
+
const args = _parseArguments(options), opts = args[0];
|
|
75474
|
+
_assertAndSanitizeOptions(opts);
|
|
75475
|
+
let tries = opts.tries;
|
|
75476
|
+
do {
|
|
75477
|
+
const name = _generateTmpName(opts);
|
|
75478
|
+
try {
|
|
75479
|
+
fs6.statSync(name);
|
|
75480
|
+
} catch (e2) {
|
|
75481
|
+
return name;
|
|
75482
|
+
}
|
|
75483
|
+
} while (tries-- > 0);
|
|
75484
|
+
throw new Error("Could not get a unique tmp filename, max tries reached");
|
|
75485
|
+
}
|
|
75486
|
+
function file(options, callback) {
|
|
75487
|
+
const args = _parseArguments(options, callback), opts = args[0], cb = args[1];
|
|
75488
|
+
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
75489
|
+
if (err) return cb(err);
|
|
75490
|
+
fs6.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err2, fd) {
|
|
75491
|
+
if (err2) return cb(err2);
|
|
75492
|
+
if (opts.discardDescriptor) {
|
|
75493
|
+
return fs6.close(fd, function _discardCallback(possibleErr) {
|
|
75494
|
+
return cb(possibleErr, name, void 0, _prepareTmpFileRemoveCallback(name, -1, opts, false));
|
|
75495
|
+
});
|
|
75496
|
+
} else {
|
|
75497
|
+
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
75498
|
+
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, false));
|
|
75499
|
+
}
|
|
75500
|
+
});
|
|
75501
|
+
});
|
|
75502
|
+
}
|
|
75503
|
+
function fileSync(options) {
|
|
75504
|
+
const args = _parseArguments(options), opts = args[0];
|
|
75505
|
+
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
75506
|
+
const name = tmpNameSync(opts);
|
|
75507
|
+
var fd = fs6.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE);
|
|
75508
|
+
if (opts.discardDescriptor) {
|
|
75509
|
+
fs6.closeSync(fd);
|
|
75510
|
+
fd = void 0;
|
|
75511
|
+
}
|
|
75512
|
+
return {
|
|
75513
|
+
name,
|
|
75514
|
+
fd,
|
|
75515
|
+
removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, true)
|
|
75516
|
+
};
|
|
75517
|
+
}
|
|
75518
|
+
function dir(options, callback) {
|
|
75519
|
+
const args = _parseArguments(options, callback), opts = args[0], cb = args[1];
|
|
75520
|
+
tmpName(opts, function _tmpNameCreated(err, name) {
|
|
75521
|
+
if (err) return cb(err);
|
|
75522
|
+
fs6.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err2) {
|
|
75523
|
+
if (err2) return cb(err2);
|
|
75524
|
+
cb(null, name, _prepareTmpDirRemoveCallback(name, opts, false));
|
|
75525
|
+
});
|
|
75526
|
+
});
|
|
75527
|
+
}
|
|
75528
|
+
function dirSync(options) {
|
|
75529
|
+
const args = _parseArguments(options), opts = args[0];
|
|
75530
|
+
const name = tmpNameSync(opts);
|
|
75531
|
+
fs6.mkdirSync(name, opts.mode || DIR_MODE);
|
|
75532
|
+
return {
|
|
75533
|
+
name,
|
|
75534
|
+
removeCallback: _prepareTmpDirRemoveCallback(name, opts, true)
|
|
75535
|
+
};
|
|
75536
|
+
}
|
|
75537
|
+
function _removeFileAsync(fdPath, next) {
|
|
75538
|
+
const _handler = function(err) {
|
|
75539
|
+
if (err && !_isENOENT(err)) {
|
|
75540
|
+
return next(err);
|
|
75541
|
+
}
|
|
75542
|
+
next();
|
|
75543
|
+
};
|
|
75544
|
+
if (0 <= fdPath[0])
|
|
75545
|
+
fs6.close(fdPath[0], function() {
|
|
75546
|
+
fs6.unlink(fdPath[1], _handler);
|
|
75547
|
+
});
|
|
75548
|
+
else fs6.unlink(fdPath[1], _handler);
|
|
75549
|
+
}
|
|
75550
|
+
function _removeFileSync(fdPath) {
|
|
75551
|
+
let rethrownException = null;
|
|
75552
|
+
try {
|
|
75553
|
+
if (0 <= fdPath[0]) fs6.closeSync(fdPath[0]);
|
|
75554
|
+
} catch (e2) {
|
|
75555
|
+
if (!_isEBADF(e2) && !_isENOENT(e2)) throw e2;
|
|
75556
|
+
} finally {
|
|
75557
|
+
try {
|
|
75558
|
+
fs6.unlinkSync(fdPath[1]);
|
|
75559
|
+
} catch (e2) {
|
|
75560
|
+
if (!_isENOENT(e2)) rethrownException = e2;
|
|
75561
|
+
}
|
|
75562
|
+
}
|
|
75563
|
+
if (rethrownException !== null) {
|
|
75564
|
+
throw rethrownException;
|
|
75565
|
+
}
|
|
75566
|
+
}
|
|
75567
|
+
function _prepareTmpFileRemoveCallback(name, fd, opts, sync) {
|
|
75568
|
+
const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name], sync);
|
|
75569
|
+
const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], sync, removeCallbackSync);
|
|
75570
|
+
if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
|
|
75571
|
+
return sync ? removeCallbackSync : removeCallback;
|
|
75572
|
+
}
|
|
75573
|
+
function _prepareTmpDirRemoveCallback(name, opts, sync) {
|
|
75574
|
+
const removeFunction = opts.unsafeCleanup ? rimraf : fs6.rmdir.bind(fs6);
|
|
75575
|
+
const removeFunctionSync = opts.unsafeCleanup ? FN_RIMRAF_SYNC : FN_RMDIR_SYNC;
|
|
75576
|
+
const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name, sync);
|
|
75577
|
+
const removeCallback = _prepareRemoveCallback(removeFunction, name, sync, removeCallbackSync);
|
|
75578
|
+
if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
|
|
75579
|
+
return sync ? removeCallbackSync : removeCallback;
|
|
75580
|
+
}
|
|
75581
|
+
function _prepareRemoveCallback(removeFunction, fileOrDirName, sync, cleanupCallbackSync) {
|
|
75582
|
+
let called = false;
|
|
75583
|
+
return function _cleanupCallback(next) {
|
|
75584
|
+
if (!called) {
|
|
75585
|
+
const toRemove = cleanupCallbackSync || _cleanupCallback;
|
|
75586
|
+
const index = _removeObjects.indexOf(toRemove);
|
|
75587
|
+
if (index >= 0) _removeObjects.splice(index, 1);
|
|
75588
|
+
called = true;
|
|
75589
|
+
if (sync || removeFunction === FN_RMDIR_SYNC || removeFunction === FN_RIMRAF_SYNC) {
|
|
75590
|
+
return removeFunction(fileOrDirName);
|
|
75591
|
+
} else {
|
|
75592
|
+
return removeFunction(fileOrDirName, next || function() {
|
|
75593
|
+
});
|
|
75594
|
+
}
|
|
75595
|
+
}
|
|
75596
|
+
};
|
|
75597
|
+
}
|
|
75598
|
+
function _garbageCollector() {
|
|
75599
|
+
if (!_gracefulCleanup) return;
|
|
75600
|
+
while (_removeObjects.length) {
|
|
75601
|
+
try {
|
|
75602
|
+
_removeObjects[0]();
|
|
75603
|
+
} catch (e2) {
|
|
75604
|
+
}
|
|
75605
|
+
}
|
|
75606
|
+
}
|
|
75607
|
+
function _randomChars(howMany) {
|
|
75608
|
+
let value = [], rnd = null;
|
|
75609
|
+
try {
|
|
75610
|
+
rnd = crypto6.randomBytes(howMany);
|
|
75611
|
+
} catch (e2) {
|
|
75612
|
+
rnd = crypto6.pseudoRandomBytes(howMany);
|
|
75613
|
+
}
|
|
75614
|
+
for (var i = 0; i < howMany; i++) {
|
|
75615
|
+
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
|
|
75616
|
+
}
|
|
75617
|
+
return value.join("");
|
|
75618
|
+
}
|
|
75619
|
+
function _isBlank(s) {
|
|
75620
|
+
return s === null || _isUndefined(s) || !s.trim();
|
|
75621
|
+
}
|
|
75622
|
+
function _isUndefined(obj) {
|
|
75623
|
+
return typeof obj === "undefined";
|
|
75624
|
+
}
|
|
75625
|
+
function _parseArguments(options, callback) {
|
|
75626
|
+
if (typeof options === "function") {
|
|
75627
|
+
return [{}, options];
|
|
75628
|
+
}
|
|
75629
|
+
if (_isUndefined(options)) {
|
|
75630
|
+
return [{}, callback];
|
|
75631
|
+
}
|
|
75632
|
+
const actualOptions = {};
|
|
75633
|
+
for (const key2 of Object.getOwnPropertyNames(options)) {
|
|
75634
|
+
actualOptions[key2] = options[key2];
|
|
75635
|
+
}
|
|
75636
|
+
return [actualOptions, callback];
|
|
75637
|
+
}
|
|
75638
|
+
function _generateTmpName(opts) {
|
|
75639
|
+
const tmpDir = opts.tmpdir;
|
|
75640
|
+
if (!_isUndefined(opts.name))
|
|
75641
|
+
return path3.join(tmpDir, opts.dir, opts.name);
|
|
75642
|
+
if (!_isUndefined(opts.template))
|
|
75643
|
+
return path3.join(tmpDir, opts.dir, opts.template).replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
75644
|
+
const name = [
|
|
75645
|
+
opts.prefix ? opts.prefix : "tmp",
|
|
75646
|
+
"-",
|
|
75647
|
+
process.pid,
|
|
75648
|
+
"-",
|
|
75649
|
+
_randomChars(12),
|
|
75650
|
+
opts.postfix ? "-" + opts.postfix : ""
|
|
75651
|
+
].join("");
|
|
75652
|
+
return path3.join(tmpDir, opts.dir, name);
|
|
75653
|
+
}
|
|
75654
|
+
function _assertAndSanitizeOptions(options) {
|
|
75655
|
+
options.tmpdir = _getTmpDir(options);
|
|
75656
|
+
const tmpDir = options.tmpdir;
|
|
75657
|
+
if (!_isUndefined(options.name))
|
|
75658
|
+
_assertIsRelative(options.name, "name", tmpDir);
|
|
75659
|
+
if (!_isUndefined(options.dir))
|
|
75660
|
+
_assertIsRelative(options.dir, "dir", tmpDir);
|
|
75661
|
+
if (!_isUndefined(options.template)) {
|
|
75662
|
+
_assertIsRelative(options.template, "template", tmpDir);
|
|
75663
|
+
if (!options.template.match(TEMPLATE_PATTERN))
|
|
75664
|
+
throw new Error(`Invalid template, found "${options.template}".`);
|
|
75665
|
+
}
|
|
75666
|
+
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0)
|
|
75667
|
+
throw new Error(`Invalid tries, found "${options.tries}".`);
|
|
75668
|
+
options.tries = _isUndefined(options.name) ? options.tries || DEFAULT_TRIES : 1;
|
|
75669
|
+
options.keep = !!options.keep;
|
|
75670
|
+
options.detachDescriptor = !!options.detachDescriptor;
|
|
75671
|
+
options.discardDescriptor = !!options.discardDescriptor;
|
|
75672
|
+
options.unsafeCleanup = !!options.unsafeCleanup;
|
|
75673
|
+
options.dir = _isUndefined(options.dir) ? "" : path3.relative(tmpDir, _resolvePath(options.dir, tmpDir));
|
|
75674
|
+
options.template = _isUndefined(options.template) ? void 0 : path3.relative(tmpDir, _resolvePath(options.template, tmpDir));
|
|
75675
|
+
options.template = _isBlank(options.template) ? void 0 : path3.relative(options.dir, options.template);
|
|
75676
|
+
options.name = _isUndefined(options.name) ? void 0 : options.name;
|
|
75677
|
+
options.prefix = _isUndefined(options.prefix) ? "" : options.prefix;
|
|
75678
|
+
options.postfix = _isUndefined(options.postfix) ? "" : options.postfix;
|
|
75679
|
+
}
|
|
75680
|
+
function _resolvePath(name, tmpDir) {
|
|
75681
|
+
if (name.startsWith(tmpDir)) {
|
|
75682
|
+
return path3.resolve(name);
|
|
75683
|
+
} else {
|
|
75684
|
+
return path3.resolve(path3.join(tmpDir, name));
|
|
75685
|
+
}
|
|
75686
|
+
}
|
|
75687
|
+
function _assertIsRelative(name, option, tmpDir) {
|
|
75688
|
+
if (option === "name") {
|
|
75689
|
+
if (path3.isAbsolute(name))
|
|
75690
|
+
throw new Error(`${option} option must not contain an absolute path, found "${name}".`);
|
|
75691
|
+
let basename = path3.basename(name);
|
|
75692
|
+
if (basename === ".." || basename === "." || basename !== name)
|
|
75693
|
+
throw new Error(`${option} option must not contain a path, found "${name}".`);
|
|
75694
|
+
} else {
|
|
75695
|
+
if (path3.isAbsolute(name) && !name.startsWith(tmpDir)) {
|
|
75696
|
+
throw new Error(`${option} option must be relative to "${tmpDir}", found "${name}".`);
|
|
75697
|
+
}
|
|
75698
|
+
let resolvedPath = _resolvePath(name, tmpDir);
|
|
75699
|
+
if (!resolvedPath.startsWith(tmpDir))
|
|
75700
|
+
throw new Error(`${option} option must be relative to "${tmpDir}", found "${resolvedPath}".`);
|
|
75701
|
+
}
|
|
75702
|
+
}
|
|
75703
|
+
function _isEBADF(error) {
|
|
75704
|
+
return _isExpectedError(error, -EBADF, "EBADF");
|
|
75705
|
+
}
|
|
75706
|
+
function _isENOENT(error) {
|
|
75707
|
+
return _isExpectedError(error, -ENOENT, "ENOENT");
|
|
75708
|
+
}
|
|
75709
|
+
function _isExpectedError(error, errno, code) {
|
|
75710
|
+
return IS_WIN32 ? error.code === code : error.code === code && error.errno === errno;
|
|
75711
|
+
}
|
|
75712
|
+
function setGracefulCleanup() {
|
|
75713
|
+
_gracefulCleanup = true;
|
|
75714
|
+
}
|
|
75715
|
+
function _getTmpDir(options) {
|
|
75716
|
+
return path3.resolve(options && options.tmpdir || os4.tmpdir());
|
|
75717
|
+
}
|
|
75718
|
+
process.addListener(EXIT, _garbageCollector);
|
|
75719
|
+
Object.defineProperty(module2.exports, "tmpdir", {
|
|
75720
|
+
enumerable: true,
|
|
75721
|
+
configurable: false,
|
|
75722
|
+
get: function() {
|
|
75723
|
+
return _getTmpDir();
|
|
75724
|
+
}
|
|
75725
|
+
});
|
|
75726
|
+
module2.exports.dir = dir;
|
|
75727
|
+
module2.exports.dirSync = dirSync;
|
|
75728
|
+
module2.exports.file = file;
|
|
75729
|
+
module2.exports.fileSync = fileSync;
|
|
75730
|
+
module2.exports.tmpName = tmpName;
|
|
75731
|
+
module2.exports.tmpNameSync = tmpNameSync;
|
|
75732
|
+
module2.exports.setGracefulCleanup = setGracefulCleanup;
|
|
75733
|
+
}
|
|
75734
|
+
});
|
|
75735
|
+
|
|
75422
75736
|
// node_modules/console-table-printer/dist/src/utils/colored-console-line.js
|
|
75423
75737
|
var require_colored_console_line = __commonJS({
|
|
75424
75738
|
"node_modules/console-table-printer/dist/src/utils/colored-console-line.js"(exports2) {
|
|
@@ -108745,7 +109059,7 @@ var {
|
|
|
108745
109059
|
// package.json
|
|
108746
109060
|
var package_default = {
|
|
108747
109061
|
name: "@capgo/cli",
|
|
108748
|
-
version: "4.10.
|
|
109062
|
+
version: "4.10.29",
|
|
108749
109063
|
description: "A CLI to upload to capgo servers",
|
|
108750
109064
|
author: "github.com/riderx",
|
|
108751
109065
|
license: "Apache 2.0",
|
|
@@ -108810,7 +109124,8 @@ var package_default = {
|
|
|
108810
109124
|
open: "^10.1.0",
|
|
108811
109125
|
prettyjson: "^1.2.5",
|
|
108812
109126
|
"prompt-sync": "^4.2.0",
|
|
108813
|
-
semver: "^7.6.2"
|
|
109127
|
+
semver: "^7.6.2",
|
|
109128
|
+
tmp: "^0.2.3"
|
|
108814
109129
|
},
|
|
108815
109130
|
devDependencies: {
|
|
108816
109131
|
"@antfu/eslint-config": "^2.20.0",
|
|
@@ -108822,6 +109137,7 @@ var package_default = {
|
|
|
108822
109137
|
"@types/prettyjson": "^0.0.33",
|
|
108823
109138
|
"@types/prompt-sync": "^4.2.3",
|
|
108824
109139
|
"@types/semver": "^7.5.8",
|
|
109140
|
+
"@types/tmp": "^0.2.6",
|
|
108825
109141
|
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
108826
109142
|
"@typescript-eslint/parser": "^7.12.0",
|
|
108827
109143
|
esbuild: "^0.21.4",
|
|
@@ -110775,6 +111091,7 @@ var import_node_fs11 = require("node:fs");
|
|
|
110775
111091
|
var import_node_child_process6 = require("node:child_process");
|
|
110776
111092
|
var import_node_process16 = __toESM(require("node:process"));
|
|
110777
111093
|
var import_semver = __toESM(require_semver6());
|
|
111094
|
+
var import_tmp = __toESM(require_tmp());
|
|
110778
111095
|
|
|
110779
111096
|
// src/app/debug.ts
|
|
110780
111097
|
var import_node_process10 = __toESM(require("node:process"));
|
|
@@ -111970,6 +112287,55 @@ var codeInject = "CapacitorUpdater.notifyAppReady()";
|
|
|
111970
112287
|
var regexImport = /import.*from.*/g;
|
|
111971
112288
|
var defaultChannel = "production";
|
|
111972
112289
|
var execOption = { stdio: "pipe" };
|
|
112290
|
+
var tmpObject;
|
|
112291
|
+
function readTmpObj() {
|
|
112292
|
+
if (!tmpObject) {
|
|
112293
|
+
tmpObject = (0, import_node_fs11.readdirSync)(import_tmp.default.tmpdir).map((name) => {
|
|
112294
|
+
return { name, full: `${import_tmp.default.tmpdir}/${name}` };
|
|
112295
|
+
}).find((obj) => obj.name.startsWith("capgocli"))?.full ?? import_tmp.default.fileSync({ prefix: "capgocli" }).name;
|
|
112296
|
+
}
|
|
112297
|
+
}
|
|
112298
|
+
function markStepDone(step) {
|
|
112299
|
+
try {
|
|
112300
|
+
readTmpObj();
|
|
112301
|
+
(0, import_node_fs11.writeFileSync)(tmpObject, JSON.stringify({ step_done: step }));
|
|
112302
|
+
} catch (err) {
|
|
112303
|
+
f2.error(`Cannot mark step as done in the CLI, error:
|
|
112304
|
+
${err}`);
|
|
112305
|
+
f2.warn("Onboarding will continue but please report it to the capgo team!");
|
|
112306
|
+
}
|
|
112307
|
+
}
|
|
112308
|
+
async function readStepsDone(orgId, snag) {
|
|
112309
|
+
try {
|
|
112310
|
+
readTmpObj();
|
|
112311
|
+
const rawData = (0, import_node_fs11.readFileSync)(tmpObject, "utf-8");
|
|
112312
|
+
if (!rawData || rawData.length === 0)
|
|
112313
|
+
return void 0;
|
|
112314
|
+
const { step_done } = JSON.parse(rawData);
|
|
112315
|
+
f2.info(`You have already got to the step ${step_done}/10 in the previous session`);
|
|
112316
|
+
const skipSteps = await se({ message: "Would you like to continue from where you left off?" });
|
|
112317
|
+
await cancelCommand2(skipSteps, orgId, snag);
|
|
112318
|
+
if (skipSteps)
|
|
112319
|
+
return step_done;
|
|
112320
|
+
return void 0;
|
|
112321
|
+
} catch (err) {
|
|
112322
|
+
f2.error(`Cannot read which steps have been compleated, error:
|
|
112323
|
+
${err}`);
|
|
112324
|
+
f2.warn("Onboarding will continue but please report it to the capgo team!");
|
|
112325
|
+
return void 0;
|
|
112326
|
+
}
|
|
112327
|
+
}
|
|
112328
|
+
function cleanupStepsDone() {
|
|
112329
|
+
if (!tmpObject) {
|
|
112330
|
+
return;
|
|
112331
|
+
}
|
|
112332
|
+
try {
|
|
112333
|
+
(0, import_node_fs11.rmSync)(tmpObject);
|
|
112334
|
+
} catch (err) {
|
|
112335
|
+
f2.error(`Cannot delete the tmp steps file.
|
|
112336
|
+
Error: ${err}`);
|
|
112337
|
+
}
|
|
112338
|
+
}
|
|
111973
112339
|
async function cancelCommand2(command, orgId, snag) {
|
|
111974
112340
|
if (eD(command)) {
|
|
111975
112341
|
await markSnag("onboarding-v2", orgId, snag, "canceled", "\u{1F937}");
|
|
@@ -112233,18 +112599,45 @@ async function initApp(apikeyCommand, appId, options) {
|
|
|
112233
112599
|
await verifyUser(supabase, apikey, ["upload", "all", "read", "write"]);
|
|
112234
112600
|
const organization = await getOrganization(supabase, ["admin", "super_admin"]);
|
|
112235
112601
|
const orgId = organization.gid;
|
|
112602
|
+
const stepToSkip = await readStepsDone(orgId, snag) ?? 0;
|
|
112236
112603
|
try {
|
|
112237
|
-
|
|
112238
|
-
|
|
112239
|
-
|
|
112240
|
-
|
|
112241
|
-
|
|
112242
|
-
|
|
112243
|
-
|
|
112244
|
-
|
|
112245
|
-
|
|
112604
|
+
if (stepToSkip < 1)
|
|
112605
|
+
await markStep(orgId, snag, 1);
|
|
112606
|
+
if (stepToSkip < 2) {
|
|
112607
|
+
await step2(organization, snag, appId, options);
|
|
112608
|
+
markStepDone(2);
|
|
112609
|
+
}
|
|
112610
|
+
if (stepToSkip < 3) {
|
|
112611
|
+
await step3(orgId, snag, apikey, appId);
|
|
112612
|
+
markStepDone(3);
|
|
112613
|
+
}
|
|
112614
|
+
if (stepToSkip < 4) {
|
|
112615
|
+
await step4(orgId, snag, apikey, appId);
|
|
112616
|
+
markStepDone(4);
|
|
112617
|
+
}
|
|
112618
|
+
if (stepToSkip < 5) {
|
|
112619
|
+
await step5(orgId, snag, apikey, appId);
|
|
112620
|
+
markStepDone(5);
|
|
112621
|
+
}
|
|
112622
|
+
if (stepToSkip < 6) {
|
|
112623
|
+
await step6(orgId, snag, apikey, appId);
|
|
112624
|
+
markStepDone(6);
|
|
112625
|
+
}
|
|
112626
|
+
if (stepToSkip < 7) {
|
|
112627
|
+
await step7(orgId, snag, apikey, appId);
|
|
112628
|
+
markStepDone(7);
|
|
112629
|
+
}
|
|
112630
|
+
if (stepToSkip < 8) {
|
|
112631
|
+
await step8(orgId, snag, apikey, appId);
|
|
112632
|
+
markStepDone(8);
|
|
112633
|
+
}
|
|
112634
|
+
if (stepToSkip < 9) {
|
|
112635
|
+
await step9(orgId, snag);
|
|
112636
|
+
markStepDone(9);
|
|
112637
|
+
}
|
|
112246
112638
|
await step10(orgId, snag, apikey, appId);
|
|
112247
112639
|
await markStep(orgId, snag, 0);
|
|
112640
|
+
cleanupStepsDone();
|
|
112248
112641
|
} catch (e2) {
|
|
112249
112642
|
console.error(e2);
|
|
112250
112643
|
f2.error(`Error during onboarding, please try again later`);
|
|
@@ -113248,6 +113641,15 @@ deep-extend/lib/deep-extend.js:
|
|
|
113248
113641
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
113249
113642
|
*)
|
|
113250
113643
|
|
|
113644
|
+
tmp/lib/tmp.js:
|
|
113645
|
+
(*!
|
|
113646
|
+
* Tmp
|
|
113647
|
+
*
|
|
113648
|
+
* Copyright (c) 2011-2017 KARASZI Istvan <github@spam.raszi.hu>
|
|
113649
|
+
*
|
|
113650
|
+
* MIT Licensed
|
|
113651
|
+
*)
|
|
113652
|
+
|
|
113251
113653
|
tslib/tslib.es6.js:
|
|
113252
113654
|
(*! *****************************************************************************
|
|
113253
113655
|
Copyright (c) Microsoft Corporation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/cli",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.29",
|
|
4
4
|
"description": "A CLI to upload to capgo servers",
|
|
5
5
|
"author": "github.com/riderx",
|
|
6
6
|
"license": "Apache 2.0",
|
|
@@ -65,7 +65,8 @@
|
|
|
65
65
|
"open": "^10.1.0",
|
|
66
66
|
"prettyjson": "^1.2.5",
|
|
67
67
|
"prompt-sync": "^4.2.0",
|
|
68
|
-
"semver": "^7.6.2"
|
|
68
|
+
"semver": "^7.6.2",
|
|
69
|
+
"tmp": "^0.2.3"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@antfu/eslint-config": "^2.20.0",
|
|
@@ -77,6 +78,7 @@
|
|
|
77
78
|
"@types/prettyjson": "^0.0.33",
|
|
78
79
|
"@types/prompt-sync": "^4.2.3",
|
|
79
80
|
"@types/semver": "^7.5.8",
|
|
81
|
+
"@types/tmp": "^0.2.6",
|
|
80
82
|
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
81
83
|
"@typescript-eslint/parser": "^7.12.0",
|
|
82
84
|
"esbuild": "^0.21.4",
|
package/src/init.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from 'node:fs'
|
|
1
|
+
import { readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
2
|
import type { ExecSyncOptions } from 'node:child_process'
|
|
3
3
|
import { execSync, spawnSync } from 'node:child_process'
|
|
4
4
|
import process from 'node:process'
|
|
5
5
|
import * as p from '@clack/prompts'
|
|
6
6
|
import type LogSnag from 'logsnag'
|
|
7
7
|
import semver from 'semver'
|
|
8
|
+
import tmp from 'tmp'
|
|
8
9
|
import { markSnag, waitLog } from './app/debug'
|
|
9
10
|
import { createKey } from './key'
|
|
10
11
|
import { addChannel } from './channel/add'
|
|
@@ -26,6 +27,63 @@ const regexImport = /import.*from.*/g
|
|
|
26
27
|
const defaultChannel = 'production'
|
|
27
28
|
const execOption = { stdio: 'pipe' }
|
|
28
29
|
|
|
30
|
+
let tmpObject: tmp.FileResult['name'] | undefined
|
|
31
|
+
|
|
32
|
+
function readTmpObj() {
|
|
33
|
+
if (!tmpObject) {
|
|
34
|
+
tmpObject = readdirSync(tmp.tmpdir)
|
|
35
|
+
.map((name) => { return { name, full: `${tmp.tmpdir}/${name}` } })
|
|
36
|
+
.find(obj => obj.name.startsWith('capgocli'))?.full
|
|
37
|
+
?? tmp.fileSync({ prefix: 'capgocli' }).name
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function markStepDone(step: number) {
|
|
42
|
+
try {
|
|
43
|
+
readTmpObj()
|
|
44
|
+
writeFileSync(tmpObject!, JSON.stringify({ step_done: step }))
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
p.log.error(`Cannot mark step as done in the CLI, error:\n${err}`)
|
|
48
|
+
p.log.warn('Onboarding will continue but please report it to the capgo team!')
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function readStepsDone(orgId: string, snag: LogSnag): Promise<number | undefined> {
|
|
53
|
+
try {
|
|
54
|
+
readTmpObj()
|
|
55
|
+
const rawData = readFileSync(tmpObject!, 'utf-8')
|
|
56
|
+
if (!rawData || rawData.length === 0)
|
|
57
|
+
return undefined
|
|
58
|
+
|
|
59
|
+
const { step_done } = JSON.parse(rawData)
|
|
60
|
+
p.log.info(`You have already got to the step ${step_done}/10 in the previous session`)
|
|
61
|
+
const skipSteps = await p.confirm({ message: 'Would you like to continue from where you left off?' })
|
|
62
|
+
await cancelCommand(skipSteps, orgId, snag)
|
|
63
|
+
if (skipSteps)
|
|
64
|
+
return step_done
|
|
65
|
+
return undefined
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
p.log.error(`Cannot read which steps have been compleated, error:\n${err}`)
|
|
69
|
+
p.log.warn('Onboarding will continue but please report it to the capgo team!')
|
|
70
|
+
return undefined
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function cleanupStepsDone() {
|
|
75
|
+
if (!tmpObject) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
rmSync(tmpObject)
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
p.log.error(`Cannot delete the tmp steps file.\nError: ${err}`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
29
87
|
async function cancelCommand(command: boolean | symbol, orgId: string, snag: LogSnag) {
|
|
30
88
|
if (p.isCancel(command)) {
|
|
31
89
|
await markSnag('onboarding-v2', orgId, snag, 'canceled', '🤷')
|
|
@@ -319,20 +377,55 @@ export async function initApp(apikeyCommand: string, appId: string, options: Sup
|
|
|
319
377
|
const organization = await getOrganization(supabase, ['admin', 'super_admin'])
|
|
320
378
|
const orgId = organization.gid
|
|
321
379
|
|
|
380
|
+
const stepToSkip = await readStepsDone(orgId, snag) ?? 0
|
|
381
|
+
|
|
322
382
|
try {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
383
|
+
if (stepToSkip < 1)
|
|
384
|
+
await markStep(orgId, snag, 1)
|
|
385
|
+
|
|
386
|
+
if (stepToSkip < 2) {
|
|
387
|
+
await step2(organization, snag, appId, options)
|
|
388
|
+
markStepDone(2)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (stepToSkip < 3) {
|
|
392
|
+
await step3(orgId, snag, apikey, appId)
|
|
393
|
+
markStepDone(3)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (stepToSkip < 4) {
|
|
397
|
+
await step4(orgId, snag, apikey, appId)
|
|
398
|
+
markStepDone(4)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (stepToSkip < 5) {
|
|
402
|
+
await step5(orgId, snag, apikey, appId)
|
|
403
|
+
markStepDone(5)
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (stepToSkip < 6) {
|
|
407
|
+
await step6(orgId, snag, apikey, appId)
|
|
408
|
+
markStepDone(6)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (stepToSkip < 7) {
|
|
412
|
+
await step7(orgId, snag, apikey, appId)
|
|
413
|
+
markStepDone(7)
|
|
414
|
+
}
|
|
334
415
|
|
|
416
|
+
if (stepToSkip < 8) {
|
|
417
|
+
await step8(orgId, snag, apikey, appId)
|
|
418
|
+
markStepDone(8)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
if (stepToSkip < 9) {
|
|
422
|
+
await step9(orgId, snag)
|
|
423
|
+
markStepDone(9)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
await step10(orgId, snag, apikey, appId)
|
|
335
427
|
await markStep(orgId, snag, 0)
|
|
428
|
+
cleanupStepsDone()
|
|
336
429
|
}
|
|
337
430
|
catch (e) {
|
|
338
431
|
console.error(e)
|