@gadgetinc/ggt 0.1.18 → 0.2.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/README.md +6 -6
- package/bin/dev.js +24 -0
- package/bin/run.js +11 -0
- package/lib/__generated__/graphql.js +6 -9
- package/lib/__generated__/graphql.js.map +1 -1
- package/lib/commands/help.js +21 -36
- package/lib/commands/help.js.map +1 -1
- package/lib/commands/list.js +29 -55
- package/lib/commands/list.js.map +1 -1
- package/lib/commands/login.js +13 -29
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/logout.js +17 -34
- package/lib/commands/logout.js.map +1 -1
- package/lib/commands/sync.js +501 -463
- package/lib/commands/sync.js.map +1 -1
- package/lib/commands/whoami.js +17 -34
- package/lib/commands/whoami.js.map +1 -1
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -1
- package/lib/utils/base-command.js +105 -146
- package/lib/utils/base-command.js.map +1 -1
- package/lib/utils/client.js +104 -113
- package/lib/utils/client.js.map +1 -1
- package/lib/utils/context.js +63 -119
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/errors.js +161 -242
- package/lib/utils/errors.js.map +1 -1
- package/lib/utils/flags.js +23 -26
- package/lib/utils/flags.js.map +1 -1
- package/lib/utils/fs-utils.js +50 -73
- package/lib/utils/fs-utils.js.map +1 -1
- package/lib/utils/help.js +19 -26
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/promise.js +32 -78
- package/lib/utils/promise.js.map +1 -1
- package/lib/utils/sleep.js +6 -11
- package/lib/utils/sleep.js.map +1 -1
- package/npm-shrinkwrap.json +7848 -7077
- package/oclif.manifest.json +1 -21
- package/package.json +49 -49
- package/bin/dev +0 -20
- package/bin/run +0 -7
- package/lib/__generated__/graphql.d.ts +0 -294
- package/lib/commands/help.d.ts +0 -14
- package/lib/commands/list.d.ts +0 -18
- package/lib/commands/login.d.ts +0 -7
- package/lib/commands/logout.d.ts +0 -7
- package/lib/commands/sync.d.ts +0 -146
- package/lib/commands/whoami.d.ts +0 -7
- package/lib/index.d.ts +0 -1
- package/lib/utils/base-command.d.ts +0 -64
- package/lib/utils/client.d.ts +0 -42
- package/lib/utils/context.d.ts +0 -57
- package/lib/utils/errors.d.ts +0 -100
- package/lib/utils/flags.d.ts +0 -1
- package/lib/utils/fs-utils.d.ts +0 -21
- package/lib/utils/help.d.ts +0 -19
- package/lib/utils/promise.d.ts +0 -35
- package/lib/utils/sleep.d.ts +0 -5
package/lib/utils/flags.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
|
|
9
|
-
const context_1 = require("./context");
|
|
10
|
-
const errors_1 = require("./errors");
|
|
11
|
-
exports.app = core_1.Flags.custom({
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import levenshtein from "fast-levenshtein";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
import { dedent } from "ts-dedent";
|
|
5
|
+
import { context } from "./context.js";
|
|
6
|
+
import { FlagError } from "./errors.js";
|
|
7
|
+
export const app = Flags.custom({
|
|
12
8
|
char: "a",
|
|
13
9
|
name: "app",
|
|
14
10
|
summary: "The Gadget application this command applies to.",
|
|
15
11
|
helpValue: "<name>",
|
|
16
|
-
parse: async (value)
|
|
17
|
-
const parsed =
|
|
18
|
-
if (!parsed)
|
|
19
|
-
|
|
12
|
+
parse: async (value)=>{
|
|
13
|
+
const parsed = RegExp("^(https:\\/\\/)?(?<name>[\\w-]+)").exec(value)?.groups?.["name"];
|
|
14
|
+
if (!parsed) throw new FlagError({
|
|
15
|
+
char: "a",
|
|
16
|
+
name: "app"
|
|
17
|
+
}, dedent`
|
|
20
18
|
The -a, --app flag must be the application's slug or URL
|
|
21
19
|
|
|
22
20
|
Examples:
|
|
@@ -27,25 +25,23 @@ exports.app = core_1.Flags.custom({
|
|
|
27
25
|
--app https://my-app.gadget.app/edit
|
|
28
26
|
`);
|
|
29
27
|
const slug = parsed.endsWith("--development") ? parsed.slice(0, -"--development".length) : parsed;
|
|
30
|
-
const availableApps = await
|
|
31
|
-
const foundApp = availableApps.find((a)
|
|
28
|
+
const availableApps = await context.getAvailableApps();
|
|
29
|
+
const foundApp = availableApps.find((a)=>a.slug == slug);
|
|
32
30
|
if (foundApp) {
|
|
33
31
|
return foundApp.slug;
|
|
34
32
|
}
|
|
35
|
-
throw new
|
|
36
|
-
|
|
33
|
+
throw new FlagError({
|
|
34
|
+
char: "a",
|
|
35
|
+
name: "app"
|
|
36
|
+
}, availableApps.length > 0 ? dedent`
|
|
37
37
|
Unknown application:
|
|
38
38
|
|
|
39
39
|
${value}
|
|
40
40
|
|
|
41
41
|
Did you mean one of these?
|
|
42
42
|
|
|
43
|
-
${
|
|
44
|
-
|
|
45
|
-
.map((app) => `* ${app.slug}`)
|
|
46
|
-
.join("\n")}
|
|
47
|
-
`
|
|
48
|
-
: (0, ts_dedent_1.default) `
|
|
43
|
+
${_.sortBy(availableApps, (app)=>levenshtein.get(app.slug, slug)).slice(0, 10).map((app)=>`* ${app.slug}`).join("\n")}
|
|
44
|
+
` : dedent`
|
|
49
45
|
Unknown application:
|
|
50
46
|
|
|
51
47
|
${value}
|
|
@@ -54,6 +50,7 @@ exports.app = core_1.Flags.custom({
|
|
|
54
50
|
|
|
55
51
|
Visit https://gadget.new to create one!
|
|
56
52
|
`);
|
|
57
|
-
}
|
|
53
|
+
}
|
|
58
54
|
});
|
|
55
|
+
|
|
59
56
|
//# sourceMappingURL=flags.js.map
|
package/lib/utils/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/flags.ts"],"sourcesContent":["import { Flags } from \"@oclif/core\";\nimport levenshtein from \"fast-levenshtein\";\nimport _ from \"lodash\";\nimport { dedent } from \"ts-dedent\";\nimport { context } from \"./context.js\";\nimport { FlagError } from \"./errors.js\";\n\nexport const app = Flags.custom({\n char: \"a\",\n name: \"app\",\n summary: \"The Gadget application this command applies to.\",\n helpValue: \"<name>\",\n parse: async (value: string) => {\n const parsed = /^(https:\\/\\/)?(?<name>[\\w-]+)/.exec(value)?.groups?.[\"name\"];\n if (!parsed)\n throw new FlagError(\n { char: \"a\", name: \"app\" },\n dedent`\n The -a, --app flag must be the application's slug or URL\n\n Examples:\n\n --app my-app\n --app my-app.gadget.app\n --app https://my-app.gadget.app\n --app https://my-app.gadget.app/edit\n `\n );\n\n const slug = parsed.endsWith(\"--development\") ? parsed.slice(0, -\"--development\".length) : parsed;\n\n const availableApps = await context.getAvailableApps();\n const foundApp = availableApps.find((a) => a.slug == slug);\n if (foundApp) {\n return foundApp.slug;\n }\n\n throw new FlagError(\n { char: \"a\", name: \"app\" },\n availableApps.length > 0\n ? dedent`\n Unknown application:\n\n ${value}\n\n Did you mean one of these?\n\n ${_.sortBy(availableApps, (app) => levenshtein.get(app.slug, slug))\n .slice(0, 10)\n .map((app) => `* ${app.slug}`)\n .join(\"\\n\")}\n `\n : dedent`\n Unknown application:\n\n ${value}\n\n It doesn't look like you have any applications.\n\n Visit https://gadget.new to create one!\n `\n );\n },\n});\n"],"names":["Flags","levenshtein","_","dedent","context","FlagError","app","custom","char","name","summary","helpValue","parse","value","parsed","exec","groups","slug","endsWith","slice","length","availableApps","getAvailableApps","foundApp","find","a","sortBy","get","map","join"],"mappings":"AAAA,SAASA,KAAK,QAAQ,cAAc;AACpC,OAAOC,iBAAiB,mBAAmB;AAC3C,OAAOC,OAAO,SAAS;AACvB,SAASC,MAAM,QAAQ,YAAY;AACnC,SAASC,OAAO,QAAQ,eAAe;AACvC,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,MAAMC,MAAMN,MAAMO,MAAM,CAAC;IAC9BC,MAAM;IACNC,MAAM;IACNC,SAAS;IACTC,WAAW;IACXC,OAAO,OAAOC;QACZ,MAAMC,SAAS,2CAAgCC,IAAI,CAACF,QAAQG,QAAQ,CAAC,OAAO;QAC5E,IAAI,CAACF,QACH,MAAM,IAAIT,UACR;YAAEG,MAAM;YAAKC,MAAM;QAAM,GACzBN,MAAM,CAAC;;;;;;;;;QASP,CAAC;QAGL,MAAMc,OAAOH,OAAOI,QAAQ,CAAC,mBAAmBJ,OAAOK,KAAK,CAAC,GAAG,CAAC,gBAAgBC,MAAM,IAAIN;QAE3F,MAAMO,gBAAgB,MAAMjB,QAAQkB,gBAAgB;QACpD,MAAMC,WAAWF,cAAcG,IAAI,CAAC,CAACC,IAAMA,EAAER,IAAI,IAAIA;QACrD,IAAIM,UAAU;YACZ,OAAOA,SAASN,IAAI;QACtB;QAEA,MAAM,IAAIZ,UACR;YAAEG,MAAM;YAAKC,MAAM;QAAM,GACzBY,cAAcD,MAAM,GAAG,IACnBjB,MAAM,CAAC;;;gBAGD,EAAEU,MAAM;;;;gBAIR,EAAEX,EAAEwB,MAAM,CAACL,eAAe,CAACf,MAAQL,YAAY0B,GAAG,CAACrB,IAAIW,IAAI,EAAEA,OAC1DE,KAAK,CAAC,GAAG,IACTS,GAAG,CAAC,CAACtB,MAAQ,CAAC,EAAE,EAAEA,IAAIW,IAAI,CAAC,CAAC,EAC5BY,IAAI,CAAC,MAAM;YAClB,CAAC,GACH1B,MAAM,CAAC;;;gBAGD,EAAEU,MAAM;;;;;YAKZ,CAAC;IAEX;AACF,GAAG"}
|
package/lib/utils/fs-utils.js
CHANGED
|
@@ -1,101 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
-
const debug = (0, debug_1.default)("ggt:fs-utils");
|
|
10
|
-
class FSIgnorer {
|
|
11
|
-
constructor(_rootDir, _alwaysIgnore) {
|
|
12
|
-
Object.defineProperty(this, "_rootDir", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: _rootDir
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(this, "_alwaysIgnore", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: _alwaysIgnore
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(this, "filepath", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: path_1.default.join(this._rootDir, ".ignore")
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(this, "_ignorer", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
configurable: true,
|
|
33
|
-
writable: true,
|
|
34
|
-
value: void 0
|
|
35
|
-
});
|
|
36
|
-
this.reload();
|
|
37
|
-
}
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import Debug from "debug";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import ignore from "ignore";
|
|
5
|
+
import path from "path";
|
|
6
|
+
const debug = Debug("ggt:fs-utils");
|
|
7
|
+
export class FSIgnorer {
|
|
38
8
|
ignores(filepath) {
|
|
39
|
-
const relative =
|
|
40
|
-
if (relative == "")
|
|
41
|
-
|
|
9
|
+
const relative = path.isAbsolute(filepath) ? path.relative(this._rootDir, filepath) : filepath;
|
|
10
|
+
if (relative == "") return false;
|
|
11
|
+
// anything above the root dir is ignored
|
|
12
|
+
if (relative == "..") {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
42
15
|
return this._ignorer.ignores(relative);
|
|
43
16
|
}
|
|
44
17
|
reload() {
|
|
45
|
-
this._ignorer =
|
|
18
|
+
this._ignorer = ignore.default();
|
|
46
19
|
this._ignorer.add(this._alwaysIgnore);
|
|
47
20
|
try {
|
|
48
|
-
this._ignorer.add(
|
|
21
|
+
this._ignorer.add(fs.readFileSync(this.filepath, "utf-8"));
|
|
49
22
|
debug("reloaded ignore rules from %s", this.filepath);
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
23
|
+
} catch (error) {
|
|
52
24
|
ignoreEnoent(error);
|
|
53
25
|
}
|
|
54
26
|
}
|
|
27
|
+
constructor(_rootDir, _alwaysIgnore){
|
|
28
|
+
_define_property(this, "_rootDir", void 0);
|
|
29
|
+
_define_property(this, "_alwaysIgnore", void 0);
|
|
30
|
+
_define_property(this, "filepath", void 0);
|
|
31
|
+
_define_property(this, "_ignorer", void 0);
|
|
32
|
+
this._rootDir = _rootDir;
|
|
33
|
+
this._alwaysIgnore = _alwaysIgnore;
|
|
34
|
+
this.filepath = path.join(this._rootDir, ".ignore");
|
|
35
|
+
this.reload();
|
|
36
|
+
}
|
|
55
37
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (options.ignorer?.ignores(dir))
|
|
59
|
-
return;
|
|
38
|
+
export async function* walkDir(dir, options = {}) {
|
|
39
|
+
if (options.ignorer?.ignores(dir)) return;
|
|
60
40
|
if (await isEmptyDir(dir)) {
|
|
61
41
|
yield `${dir}/`;
|
|
62
42
|
return;
|
|
63
43
|
}
|
|
64
|
-
for await (const entry of await
|
|
65
|
-
const filepath =
|
|
44
|
+
for await (const entry of (await fs.opendir(dir))){
|
|
45
|
+
const filepath = path.join(dir, entry.name);
|
|
66
46
|
if (entry.isDirectory()) {
|
|
67
47
|
yield* walkDir(filepath, options);
|
|
68
|
-
}
|
|
69
|
-
else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {
|
|
48
|
+
} else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {
|
|
70
49
|
yield filepath;
|
|
71
50
|
}
|
|
72
51
|
}
|
|
73
52
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (options.ignorer?.ignores(dir))
|
|
77
|
-
return;
|
|
53
|
+
export function* walkDirSync(dir, options = {}) {
|
|
54
|
+
if (options.ignorer?.ignores(dir)) return;
|
|
78
55
|
if (isEmptyDirSync(dir)) {
|
|
79
56
|
yield `${dir}/`;
|
|
80
57
|
return;
|
|
81
58
|
}
|
|
82
|
-
for (const entry of
|
|
83
|
-
|
|
59
|
+
for (const entry of fs.readdirSync(dir, {
|
|
60
|
+
withFileTypes: true
|
|
61
|
+
})){
|
|
62
|
+
const filepath = path.join(dir, entry.name);
|
|
84
63
|
if (entry.isDirectory()) {
|
|
85
64
|
yield* walkDirSync(filepath, options);
|
|
86
|
-
}
|
|
87
|
-
else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {
|
|
65
|
+
} else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {
|
|
88
66
|
yield filepath;
|
|
89
67
|
}
|
|
90
68
|
}
|
|
91
69
|
}
|
|
92
|
-
|
|
93
|
-
|
|
70
|
+
export function isEmptyDirSync(dir, opts = {
|
|
71
|
+
ignoreEnoent: true
|
|
72
|
+
}) {
|
|
94
73
|
try {
|
|
95
|
-
const files =
|
|
74
|
+
const files = fs.readdirSync(dir);
|
|
96
75
|
return files.length === 0;
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
76
|
+
} catch (error) {
|
|
99
77
|
if (opts.ignoreEnoent) {
|
|
100
78
|
ignoreEnoent(error);
|
|
101
79
|
return true;
|
|
@@ -103,13 +81,13 @@ function isEmptyDirSync(dir, opts = { ignoreEnoent: true }) {
|
|
|
103
81
|
throw error;
|
|
104
82
|
}
|
|
105
83
|
}
|
|
106
|
-
|
|
107
|
-
|
|
84
|
+
export async function isEmptyDir(dir, opts = {
|
|
85
|
+
ignoreEnoent: true
|
|
86
|
+
}) {
|
|
108
87
|
try {
|
|
109
|
-
const files = await
|
|
88
|
+
const files = await fs.readdir(dir);
|
|
110
89
|
return files.length === 0;
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
90
|
+
} catch (error) {
|
|
113
91
|
if (opts.ignoreEnoent) {
|
|
114
92
|
ignoreEnoent(error);
|
|
115
93
|
return true;
|
|
@@ -117,13 +95,12 @@ async function isEmptyDir(dir, opts = { ignoreEnoent: true }) {
|
|
|
117
95
|
throw error;
|
|
118
96
|
}
|
|
119
97
|
}
|
|
120
|
-
|
|
121
|
-
function ignoreEnoent(error) {
|
|
98
|
+
export function ignoreEnoent(error) {
|
|
122
99
|
if (error.code === "ENOENT") {
|
|
123
100
|
debug("ignoring ENOENT error %s", error.path);
|
|
124
101
|
return;
|
|
125
102
|
}
|
|
126
103
|
throw error;
|
|
127
104
|
}
|
|
128
|
-
|
|
105
|
+
|
|
129
106
|
//# sourceMappingURL=fs-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/fs-utils.ts"],"sourcesContent":["import Debug from \"debug\";\nimport fs from \"fs-extra\";\nimport type { Ignore } from \"ignore\";\nimport ignore from \"ignore\";\nimport path from \"path\";\n\nconst debug = Debug(\"ggt:fs-utils\");\n\nexport class FSIgnorer {\n readonly filepath;\n\n private _ignorer!: Ignore;\n\n constructor(private readonly _rootDir: string, private readonly _alwaysIgnore: string[]) {\n this.filepath = path.join(this._rootDir, \".ignore\");\n this.reload();\n }\n\n ignores(filepath: string): boolean {\n const relative = path.isAbsolute(filepath) ? path.relative(this._rootDir, filepath) : filepath;\n if (relative == \"\") return false;\n // anything above the root dir is ignored\n if (relative == \"..\") {\n return true;\n }\n return this._ignorer.ignores(relative);\n }\n\n reload(): void {\n this._ignorer = ignore.default();\n this._ignorer.add(this._alwaysIgnore);\n\n try {\n this._ignorer.add(fs.readFileSync(this.filepath, \"utf-8\"));\n debug(\"reloaded ignore rules from %s\", this.filepath);\n } catch (error) {\n ignoreEnoent(error);\n }\n }\n}\n\nexport interface WalkDirOptions {\n ignorer?: FSIgnorer;\n}\n\nexport async function* walkDir(dir: string, options: WalkDirOptions = {}): AsyncGenerator<string> {\n if (options.ignorer?.ignores(dir)) return;\n\n if (await isEmptyDir(dir)) {\n yield `${dir}/`;\n return;\n }\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkDir(filepath, options);\n } else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {\n yield filepath;\n }\n }\n}\n\nexport function* walkDirSync(dir: string, options: WalkDirOptions = {}): Generator<string> {\n if (options.ignorer?.ignores(dir)) return;\n\n if (isEmptyDirSync(dir)) {\n yield `${dir}/`;\n return;\n }\n\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const filepath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkDirSync(filepath, options);\n } else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {\n yield filepath;\n }\n }\n}\n\nexport function isEmptyDirSync(dir: string, opts = { ignoreEnoent: true }): boolean {\n try {\n const files = fs.readdirSync(dir);\n return files.length === 0;\n } catch (error) {\n if (opts.ignoreEnoent) {\n ignoreEnoent(error);\n return true;\n }\n throw error;\n }\n}\n\nexport async function isEmptyDir(dir: string, opts = { ignoreEnoent: true }): Promise<boolean> {\n try {\n const files = await fs.readdir(dir);\n return files.length === 0;\n } catch (error) {\n if (opts.ignoreEnoent) {\n ignoreEnoent(error);\n return true;\n }\n throw error;\n }\n}\n\nexport function ignoreEnoent(error: any): void {\n if (error.code === \"ENOENT\") {\n debug(\"ignoring ENOENT error %s\", error.path);\n return;\n }\n throw error;\n}\n"],"names":["Debug","fs","ignore","path","debug","FSIgnorer","ignores","filepath","relative","isAbsolute","_rootDir","_ignorer","reload","default","add","_alwaysIgnore","readFileSync","error","ignoreEnoent","constructor","join","walkDir","dir","options","ignorer","isEmptyDir","entry","opendir","name","isDirectory","isFile","walkDirSync","isEmptyDirSync","readdirSync","withFileTypes","opts","files","length","readdir","code"],"mappings":"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"}
|
package/lib/utils/help.js
CHANGED
|
@@ -1,43 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(this, "CommandHelpClass", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: CommandHelp
|
|
13
|
-
});
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import { CommandHelp as OclifCommandHelp, Help as OclifHelp } from "@oclif/core";
|
|
3
|
+
import _ from "lodash";
|
|
4
|
+
class Help extends OclifHelp {
|
|
5
|
+
constructor(...args){
|
|
6
|
+
super(...args);
|
|
7
|
+
_define_property(this, "CommandHelpClass", CommandHelp);
|
|
14
8
|
}
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
class CommandHelp extends
|
|
10
|
+
export { Help as default };
|
|
11
|
+
class CommandHelp extends OclifCommandHelp {
|
|
18
12
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
description() {
|
|
13
|
+
* By default, oclif tries to format the description so that it fit's within the terminal window. However, if the description is already
|
|
14
|
+
* formatted with `dedent`, then the description gets mangled and the help output is not pretty.
|
|
15
|
+
*
|
|
16
|
+
* This overrides the default behavior to just use the description as-is if it already exists.
|
|
17
|
+
*/ description() {
|
|
25
18
|
if (this.command.description) {
|
|
26
19
|
return this.command.description;
|
|
27
20
|
}
|
|
28
21
|
return super.description();
|
|
29
22
|
}
|
|
30
23
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if ((0, lodash_1.isString)(examples)) {
|
|
24
|
+
* Same as above, but for examples.
|
|
25
|
+
*/ examples(examples) {
|
|
26
|
+
if (_.isString(examples)) {
|
|
35
27
|
return examples;
|
|
36
28
|
}
|
|
37
|
-
if (Array.isArray(examples) && examples.every(
|
|
29
|
+
if (Array.isArray(examples) && examples.every((e)=>_.isString(e))) {
|
|
38
30
|
return examples.join("\n\n");
|
|
39
31
|
}
|
|
40
32
|
return super.examples(examples);
|
|
41
33
|
}
|
|
42
34
|
}
|
|
35
|
+
|
|
43
36
|
//# sourceMappingURL=help.js.map
|
package/lib/utils/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/help.ts"],"sourcesContent":["import type { Command } from \"@oclif/core\";\nimport { CommandHelp as OclifCommandHelp, Help as OclifHelp } from \"@oclif/core\";\nimport _ from \"lodash\";\n\nexport default class Help extends OclifHelp {\n override CommandHelpClass = CommandHelp;\n}\n\nclass CommandHelp extends OclifCommandHelp {\n /**\n * By default, oclif tries to format the description so that it fit's within the terminal window. However, if the description is already\n * formatted with `dedent`, then the description gets mangled and the help output is not pretty.\n *\n * This overrides the default behavior to just use the description as-is if it already exists.\n */\n protected override description(): string | undefined {\n if (this.command.description) {\n return this.command.description;\n }\n return super.description();\n }\n\n /**\n * Same as above, but for examples.\n */\n protected override examples(examples: string | string[] | Command.Example[] | undefined): string | undefined {\n if (_.isString(examples)) {\n return examples;\n }\n if (Array.isArray(examples) && examples.every((e) => _.isString(e))) {\n return examples.join(\"\\n\\n\");\n }\n return super.examples(examples);\n }\n}\n"],"names":["CommandHelp","OclifCommandHelp","Help","OclifHelp","_","CommandHelpClass","description","command","examples","isString","Array","isArray","every","e","join"],"mappings":";AACA,SAASA,eAAeC,gBAAgB,EAAEC,QAAQC,SAAS,QAAQ,cAAc;AACjF,OAAOC,OAAO,SAAS;AAER,MAAMF,aAAaC;;;QAChC,uBAASE,oBAAmBL;;AAC9B;AAFA,SAAqBE,kBAEpB;AAED,MAAMF,oBAAoBC;IACxB;;;;;GAKC,GACD,AAAmBK,cAAkC;QACnD,IAAI,IAAI,CAACC,OAAO,CAACD,WAAW,EAAE;YAC5B,OAAO,IAAI,CAACC,OAAO,CAACD,WAAW;QACjC;QACA,OAAO,KAAK,CAACA;IACf;IAEA;;GAEC,GACD,AAAmBE,SAASA,QAA2D,EAAsB;QAC3G,IAAIJ,EAAEK,QAAQ,CAACD,WAAW;YACxB,OAAOA;QACT;QACA,IAAIE,MAAMC,OAAO,CAACH,aAAaA,SAASI,KAAK,CAAC,CAACC,IAAMT,EAAEK,QAAQ,CAACI,KAAK;YACnE,OAAOL,SAASM,IAAI,CAAC;QACvB;QACA,OAAO,KAAK,CAACN,SAASA;IACxB;AACF"}
|
package/lib/utils/promise.js
CHANGED
|
@@ -1,59 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.PromiseSignal = exports.PromiseWrapper = void 0;
|
|
5
1
|
/**
|
|
6
2
|
* Long lived references to Promises stress the garbage collector in JS. Instead of caching resolved Promises, we cache
|
|
7
3
|
* these little data objects instead which reference the resolution or rejection of the Promise, allowing the Promise
|
|
8
4
|
* object to be free'd.
|
|
9
|
-
*/
|
|
10
|
-
class PromiseWrapper {
|
|
11
|
-
constructor(promise) {
|
|
12
|
-
Object.defineProperty(this, "resolution", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
configurable: true,
|
|
15
|
-
writable: true,
|
|
16
|
-
value: void 0
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(this, "rejection", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(this, "pendingPromise", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
configurable: true,
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
30
|
-
this.pendingPromise = promise;
|
|
31
|
-
promise
|
|
32
|
-
.then((res) => {
|
|
33
|
-
this.resolution = res;
|
|
34
|
-
return res;
|
|
35
|
-
})
|
|
36
|
-
.catch((err) => {
|
|
37
|
-
this.rejection = err;
|
|
38
|
-
})
|
|
39
|
-
.finally(() => {
|
|
40
|
-
delete this.pendingPromise;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
5
|
+
*/ import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
6
|
+
export class PromiseWrapper {
|
|
43
7
|
async unwrap() {
|
|
44
8
|
if (this.resolution) {
|
|
45
9
|
return this.resolution;
|
|
46
|
-
}
|
|
47
|
-
else if (this.rejection) {
|
|
10
|
+
} else if (this.rejection) {
|
|
48
11
|
throw this.rejection;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
12
|
+
} else {
|
|
51
13
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
52
14
|
return await this.pendingPromise;
|
|
53
15
|
}
|
|
54
16
|
}
|
|
17
|
+
constructor(promise){
|
|
18
|
+
_define_property(this, "resolution", void 0);
|
|
19
|
+
_define_property(this, "rejection", void 0);
|
|
20
|
+
_define_property(this, "pendingPromise", void 0);
|
|
21
|
+
this.pendingPromise = promise;
|
|
22
|
+
promise.then((res)=>{
|
|
23
|
+
this.resolution = res;
|
|
24
|
+
return res;
|
|
25
|
+
}).catch((err)=>{
|
|
26
|
+
this.rejection = err;
|
|
27
|
+
}).finally(()=>{
|
|
28
|
+
delete this.pendingPromise;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
55
31
|
}
|
|
56
|
-
|
|
32
|
+
let _Symbol_toStringTag = Symbol.toStringTag;
|
|
57
33
|
/**
|
|
58
34
|
* A promise that can be resolved or rejected from outside its callback.
|
|
59
35
|
*
|
|
@@ -66,39 +42,7 @@ exports.PromiseWrapper = PromiseWrapper;
|
|
|
66
42
|
* signal.resolve();
|
|
67
43
|
* });
|
|
68
44
|
* await signal;
|
|
69
|
-
*/
|
|
70
|
-
class PromiseSignal {
|
|
71
|
-
constructor() {
|
|
72
|
-
Object.defineProperty(this, _a, {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
configurable: true,
|
|
75
|
-
writable: true,
|
|
76
|
-
value: void 0
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(this, "resolve", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
configurable: true,
|
|
81
|
-
writable: true,
|
|
82
|
-
value: void 0
|
|
83
|
-
});
|
|
84
|
-
Object.defineProperty(this, "reject", {
|
|
85
|
-
enumerable: true,
|
|
86
|
-
configurable: true,
|
|
87
|
-
writable: true,
|
|
88
|
-
value: void 0
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(this, "_promise", {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
configurable: true,
|
|
93
|
-
writable: true,
|
|
94
|
-
value: void 0
|
|
95
|
-
});
|
|
96
|
-
this._promise = new PromiseWrapper(new Promise((resolve, reject) => {
|
|
97
|
-
this.resolve = resolve;
|
|
98
|
-
this.reject = reject;
|
|
99
|
-
}));
|
|
100
|
-
this[Symbol.toStringTag] = String(this._promise.pendingPromise);
|
|
101
|
-
}
|
|
45
|
+
*/ export class PromiseSignal {
|
|
102
46
|
then(onfulfilled, onrejected) {
|
|
103
47
|
return this._promise.unwrap().then(onfulfilled, onrejected);
|
|
104
48
|
}
|
|
@@ -108,7 +52,17 @@ class PromiseSignal {
|
|
|
108
52
|
finally(onfinally) {
|
|
109
53
|
return this._promise.unwrap().finally(onfinally);
|
|
110
54
|
}
|
|
55
|
+
constructor(){
|
|
56
|
+
_define_property(this, _Symbol_toStringTag, void 0);
|
|
57
|
+
_define_property(this, "resolve", void 0);
|
|
58
|
+
_define_property(this, "reject", void 0);
|
|
59
|
+
_define_property(this, "_promise", void 0);
|
|
60
|
+
this._promise = new PromiseWrapper(new Promise((resolve, reject)=>{
|
|
61
|
+
this.resolve = resolve;
|
|
62
|
+
this.reject = reject;
|
|
63
|
+
}));
|
|
64
|
+
this[Symbol.toStringTag] = String(this._promise.pendingPromise);
|
|
65
|
+
}
|
|
111
66
|
}
|
|
112
|
-
|
|
113
|
-
_a = Symbol.toStringTag;
|
|
67
|
+
|
|
114
68
|
//# sourceMappingURL=promise.js.map
|
package/lib/utils/promise.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/promise.ts"],"sourcesContent":["/**\n * Long lived references to Promises stress the garbage collector in JS. Instead of caching resolved Promises, we cache\n * these little data objects instead which reference the resolution or rejection of the Promise, allowing the Promise\n * object to be free'd.\n */\nexport class PromiseWrapper<T> {\n resolution?: T;\n rejection?: any;\n pendingPromise?: Promise<T>;\n\n constructor(promise: Promise<T>) {\n this.pendingPromise = promise;\n\n promise\n .then((res) => {\n this.resolution = res;\n return res;\n })\n .catch((err) => {\n this.rejection = err;\n })\n .finally(() => {\n delete this.pendingPromise;\n });\n }\n\n async unwrap(): Promise<T> {\n if (this.resolution) {\n return this.resolution;\n } else if (this.rejection) {\n throw this.rejection;\n } else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return await this.pendingPromise!;\n }\n }\n}\n\n/**\n * A promise that can be resolved or rejected from outside its callback.\n *\n * This is typically used when you want to await a promise that is resolved or rejected from outside the current scope,\n * such as from an event handler.\n *\n * @example\n * const signal = new PromiseSignal();\n * process.on(\"SIGINT\", () => {\n * signal.resolve();\n * });\n * await signal;\n */\nexport class PromiseSignal<T = void> implements Promise<T> {\n readonly [Symbol.toStringTag]!: string;\n\n resolve!: (value: T | PromiseLike<T>) => void;\n reject!: (reason?: any) => void;\n\n private _promise: PromiseWrapper<T>;\n\n constructor() {\n this._promise = new PromiseWrapper<T>(\n new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n })\n );\n\n this[Symbol.toStringTag] = String(this._promise.pendingPromise);\n }\n\n then<R = T, E = never>(onfulfilled?: (value: T) => R | PromiseLike<R>, onrejected?: (reason: any) => E | PromiseLike<E>): Promise<R | E> {\n return this._promise.unwrap().then(onfulfilled, onrejected);\n }\n\n catch<E = never>(onrejected?: (reason: any) => E | PromiseLike<E>): Promise<T | E> {\n return this._promise.unwrap().catch(onrejected);\n }\n\n finally(onfinally?: () => void): Promise<T> {\n return this._promise.unwrap().finally(onfinally);\n }\n}\n"],"names":["PromiseWrapper","unwrap","resolution","rejection","pendingPromise","constructor","promise","then","res","catch","err","finally","Symbol","toStringTag","PromiseSignal","onfulfilled","onrejected","_promise","onfinally","resolve","reject","Promise","String"],"mappings":"AAAA;;;;CAIC;AACD,OAAO,MAAMA;IAqBX,MAAMC,SAAqB;QACzB,IAAI,IAAI,CAACC,UAAU,EAAE;YACnB,OAAO,IAAI,CAACA,UAAU;QACxB,OAAO,IAAI,IAAI,CAACC,SAAS,EAAE;YACzB,MAAM,IAAI,CAACA,SAAS;QACtB,OAAO;YACL,oEAAoE;YACpE,OAAO,MAAM,IAAI,CAACC,cAAc;QAClC;IACF;IAzBAC,YAAYC,OAAmB,CAAE;QAJjCJ,uBAAAA,cAAAA,KAAAA;QACAC,uBAAAA,aAAAA,KAAAA;QACAC,uBAAAA,kBAAAA,KAAAA;QAGE,IAAI,CAACA,cAAc,GAAGE;QAEtBA,QACGC,IAAI,CAAC,CAACC;YACL,IAAI,CAACN,UAAU,GAAGM;YAClB,OAAOA;QACT,GACCC,KAAK,CAAC,CAACC;YACN,IAAI,CAACP,SAAS,GAAGO;QACnB,GACCC,OAAO,CAAC;YACP,OAAO,IAAI,CAACP,cAAc;QAC5B;IACJ;AAYF;IAgBYQ,sBAAAA,OAAOC,WAAW;AAd9B;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMC;IAmBXP,KAAuBQ,WAA8C,EAAEC,UAAgD,EAAkB;QACvI,OAAO,IAAI,CAACC,QAAQ,CAAChB,MAAM,GAAGM,IAAI,CAACQ,aAAaC;IAClD;IAEAP,MAAiBO,UAAgD,EAAkB;QACjF,OAAO,IAAI,CAACC,QAAQ,CAAChB,MAAM,GAAGQ,KAAK,CAACO;IACtC;IAEAL,QAAQO,SAAsB,EAAc;QAC1C,OAAO,IAAI,CAACD,QAAQ,CAAChB,MAAM,GAAGU,OAAO,CAACO;IACxC;IArBAb,aAAc;QAPd,uBAAUO,qBAAV,KAAA;QAEAO,uBAAAA,WAAAA,KAAAA;QACAC,uBAAAA,UAAAA,KAAAA;QAEA,uBAAQH,YAAR,KAAA;QAGE,IAAI,CAACA,QAAQ,GAAG,IAAIjB,eAClB,IAAIqB,QAAQ,CAACF,SAASC;YACpB,IAAI,CAACD,OAAO,GAAGA;YACf,IAAI,CAACC,MAAM,GAAGA;QAChB;QAGF,IAAI,CAACR,OAAOC,WAAW,CAAC,GAAGS,OAAO,IAAI,CAACL,QAAQ,CAACb,cAAc;IAChE;AAaF"}
|
package/lib/utils/sleep.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.sleepUntil = exports.sleep = void 0;
|
|
4
|
-
function sleep(ms = 0) {
|
|
5
|
-
return new Promise((resolve) => (ms == 0 ? setImmediate(resolve) : setTimeout(resolve, ms)));
|
|
1
|
+
export function sleep(ms = 0) {
|
|
2
|
+
return new Promise((resolve)=>ms == 0 ? setImmediate(resolve) : setTimeout(resolve, ms));
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
async function sleepUntil(fn, { interval = 0, timeout = process.env["CI"] ? 5000 : 500 } = {}) {
|
|
4
|
+
export async function sleepUntil(fn, { interval = 0, timeout = process.env["CI"] ? 5000 : 500 } = {}) {
|
|
9
5
|
const start = isFinite(timeout) && Date.now();
|
|
10
6
|
// eslint-disable-next-line no-constant-condition
|
|
11
|
-
while
|
|
12
|
-
if (fn())
|
|
13
|
-
return;
|
|
7
|
+
while(true){
|
|
8
|
+
if (fn()) return;
|
|
14
9
|
await sleep(interval);
|
|
15
10
|
if (start && Date.now() - start > timeout) {
|
|
16
11
|
const error = new Error(`Timed out after ${timeout} milliseconds`);
|
|
@@ -19,5 +14,5 @@ async function sleepUntil(fn, { interval = 0, timeout = process.env["CI"] ? 5000
|
|
|
19
14
|
}
|
|
20
15
|
}
|
|
21
16
|
}
|
|
22
|
-
|
|
17
|
+
|
|
23
18
|
//# sourceMappingURL=sleep.js.map
|
package/lib/utils/sleep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export function sleep(ms = 0): Promise<void> {\n return new Promise((resolve) => (ms == 0 ? setImmediate(resolve) : setTimeout(resolve, ms)));\n}\n\nexport async function sleepUntil(fn: () => boolean, { interval = 0, timeout = process.env[\"CI\"] ? 5000 : 500 } = {}): Promise<void> {\n const start = isFinite(timeout) && Date.now();\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (fn()) return;\n await sleep(interval);\n\n if (start && Date.now() - start > timeout) {\n const error = new Error(`Timed out after ${timeout} milliseconds`);\n Error.captureStackTrace(error, sleepUntil);\n throw error;\n }\n }\n}\n"],"names":["sleep","ms","Promise","resolve","setImmediate","setTimeout","sleepUntil","fn","interval","timeout","process","env","start","isFinite","Date","now","error","Error","captureStackTrace"],"mappings":"AAAA,OAAO,SAASA,MAAMC,KAAK,CAAC;IAC1B,OAAO,IAAIC,QAAQ,CAACC,UAAaF,MAAM,IAAIG,aAAaD,WAAWE,WAAWF,SAASF;AACzF;AAEA,OAAO,eAAeK,WAAWC,EAAiB,EAAE,EAAEC,WAAW,CAAC,EAAEC,UAAUC,QAAQC,GAAG,CAAC,KAAK,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC;IACjH,MAAMC,QAAQC,SAASJ,YAAYK,KAAKC,GAAG;IAE3C,iDAAiD;IACjD,MAAO,KAAM;QACX,IAAIR,MAAM;QACV,MAAMP,MAAMQ;QAEZ,IAAII,SAASE,KAAKC,GAAG,KAAKH,QAAQH,SAAS;YACzC,MAAMO,QAAQ,IAAIC,MAAM,CAAC,gBAAgB,EAAER,QAAQ,aAAa,CAAC;YACjEQ,MAAMC,iBAAiB,CAACF,OAAOV;YAC/B,MAAMU;QACR;IACF;AACF"}
|