@eik/cli 3.1.4 → 3.1.5
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/CHANGELOG.md +7 -0
- package/classes/alias.js +1 -1
- package/commands/alias.js +35 -69
- package/commands/init.js +75 -88
- package/commands/integrity.js +20 -33
- package/commands/login.js +51 -70
- package/commands/map-alias.js +41 -61
- package/commands/map.js +34 -48
- package/commands/meta.js +31 -47
- package/commands/npm-alias.js +32 -57
- package/commands/package-alias.js +35 -66
- package/commands/ping.js +17 -28
- package/commands/publish.js +50 -56
- package/commands/version.js +36 -42
- package/index.js +52 -48
- package/package.json +3 -3
- package/readme.md +1 -1
- package/types/classes/alias.d.ts +2 -2
- package/types/utils/defaults.d.ts +22 -0
- package/types/utils/error.d.ts +19 -0
- package/types/utils/index.d.ts +2 -2
- package/utils/command-handler.js +72 -0
- package/utils/defaults.js +79 -0
- package/utils/error.js +42 -0
- package/utils/index.js +3 -2
- package/commands/index.js +0 -27
package/commands/map-alias.js
CHANGED
@@ -1,72 +1,63 @@
|
|
1
|
-
// @deprecated in favor of `alias` command
|
2
|
-
|
3
|
-
import ora from "ora";
|
4
1
|
import Alias from "../classes/alias.js";
|
5
|
-
import { logger, getDefaults } from "../utils/index.js";
|
6
2
|
import { Alias as AliasFormatter } from "../formatters/index.js";
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
7
4
|
|
8
5
|
export const command = "map-alias <name> <version> <alias>";
|
9
6
|
|
10
7
|
export const aliases = ["ma"];
|
11
8
|
|
12
|
-
export const describe =
|
9
|
+
export const describe = "Create an alias for a map";
|
13
10
|
|
14
|
-
export const
|
15
|
-
const defaults = getDefaults(yargs.argv.config || yargs.argv.cwd);
|
11
|
+
export const deprecated = "map-alias has been replaced by alias";
|
16
12
|
|
17
|
-
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
14
|
+
export const builder = (yargs) => {
|
15
|
+
return yargs
|
18
16
|
.positional("name", {
|
19
|
-
describe:
|
17
|
+
describe: "Import map package name",
|
20
18
|
type: "string",
|
21
19
|
})
|
22
20
|
.positional("version", {
|
23
|
-
describe:
|
21
|
+
describe: "Import map version",
|
24
22
|
type: "string",
|
25
23
|
})
|
26
24
|
.positional("alias", {
|
27
|
-
describe: `Alias for a semver version. Should be the semver major component of version.`,
|
28
|
-
type: "string",
|
29
|
-
});
|
30
|
-
|
31
|
-
yargs.options({
|
32
|
-
server: {
|
33
|
-
alias: "s",
|
34
|
-
describe: "Specify location of asset server.",
|
35
|
-
// @ts-expect-error
|
36
|
-
default: defaults.server,
|
37
|
-
},
|
38
|
-
token: {
|
39
25
|
describe:
|
40
|
-
"
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
26
|
+
"Alias value, the semver major component of the import map version",
|
27
|
+
type: "string",
|
28
|
+
})
|
29
|
+
.options({
|
30
|
+
server: {
|
31
|
+
alias: "s",
|
32
|
+
describe: "Eik server address, if different from configuration file",
|
33
|
+
},
|
34
|
+
token: {
|
35
|
+
describe: "JWT used for authentication, if not using eik login",
|
36
|
+
alias: "t",
|
37
|
+
},
|
38
|
+
})
|
39
|
+
.example("eik map-alias my-map 1.0.0 1")
|
40
|
+
.example("eik map-alias my-map 1.7.3 1")
|
41
|
+
.example("eik map-alias my-map 6.3.1 6")
|
42
|
+
.example(
|
43
|
+
"eik map-alias my-map 6.3.1 6 --server https://assets.myeikserver.com",
|
44
|
+
)
|
45
|
+
.example("eik map-alias my-map 6.3.1 6 --token yourtoken");
|
56
46
|
};
|
57
47
|
|
58
|
-
export const handler =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
const log = logger(spinner, debug);
|
63
|
-
let data = {};
|
48
|
+
export const handler = commandHandler(
|
49
|
+
{ command, options: ["server"] },
|
50
|
+
async (argv, log) => {
|
51
|
+
const { debug, name, version, server, ...rest } = argv;
|
64
52
|
|
65
|
-
|
66
|
-
|
53
|
+
const data = await new Alias({
|
54
|
+
debug,
|
55
|
+
name,
|
56
|
+
version,
|
57
|
+
server,
|
58
|
+
...rest,
|
67
59
|
type: "map",
|
68
60
|
logger: log,
|
69
|
-
...argv,
|
70
61
|
}).run();
|
71
62
|
|
72
63
|
data.name = name;
|
@@ -74,22 +65,11 @@ export const handler = async (argv) => {
|
|
74
65
|
data.files = [];
|
75
66
|
|
76
67
|
const createdOrUpdated = data.update ? "Updated" : "Created";
|
68
|
+
|
77
69
|
log.info(
|
78
70
|
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
79
71
|
);
|
80
|
-
success = true;
|
81
|
-
} catch (err) {
|
82
|
-
log.warn(err.message);
|
83
|
-
}
|
84
72
|
|
85
|
-
spinner.text = "";
|
86
|
-
spinner.stopAndPersist();
|
87
|
-
if (success) {
|
88
73
|
new AliasFormatter(data).format(server);
|
89
|
-
}
|
90
|
-
|
91
|
-
}
|
92
|
-
};
|
93
|
-
|
94
|
-
export const deprecated =
|
95
|
-
'"map-alias" will be removed in a future version. Please use "alias" instead';
|
74
|
+
},
|
75
|
+
);
|
package/commands/map.js
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
import { join } from "path";
|
2
|
-
import ora from "ora";
|
3
2
|
import PublishMap from "../classes/publish/map.js";
|
4
|
-
import { logger, getDefaults } from "../utils/index.js";
|
5
3
|
import { Artifact } from "../formatters/index.js";
|
4
|
+
import { commandHandler } from "../utils/command-handler.js";
|
6
5
|
|
7
6
|
export const command = "map <name> <version> <file>";
|
8
7
|
|
9
8
|
export const aliases = ["m"];
|
10
9
|
|
11
|
-
export const describe =
|
10
|
+
export const describe = "Publish an import map to the server";
|
12
11
|
|
12
|
+
/** @type {import('yargs').CommandBuilder} */
|
13
13
|
export const builder = (yargs) => {
|
14
|
-
|
15
|
-
|
16
|
-
yargs
|
14
|
+
return yargs
|
17
15
|
.positional("name", {
|
18
16
|
describe: "Import map name.",
|
19
17
|
type: "string",
|
@@ -27,41 +25,37 @@ export const builder = (yargs) => {
|
|
27
25
|
"Path to import map file on local disk relative to the current working directory.",
|
28
26
|
type: "string",
|
29
27
|
normalize: true,
|
30
|
-
})
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
// @ts-expect-error
|
48
|
-
yargs.default("token", defaults.token, defaults.token ? "######" : "");
|
49
|
-
|
50
|
-
yargs.example(`eik map my-map 1.0.0 ./import-map.json`);
|
51
|
-
yargs.example(`eik map my-map 2.1.0 ./import-map.json --debug`);
|
52
|
-
yargs.example(
|
53
|
-
`eik map my-map 2.1.1 ./import-map.json --server https://assets.myeikserver.com`,
|
54
|
-
);
|
28
|
+
})
|
29
|
+
.options({
|
30
|
+
server: {
|
31
|
+
alias: "s",
|
32
|
+
describe: "Eik server address, if different from configuration file",
|
33
|
+
},
|
34
|
+
token: {
|
35
|
+
describe: "JWT used for authentication, if not using eik login",
|
36
|
+
alias: "t",
|
37
|
+
},
|
38
|
+
})
|
39
|
+
.example("eik map my-map 1.0.0 ./import-map.json")
|
40
|
+
.example(
|
41
|
+
"eik map my-map 2.1.1 ./import-map.json --server https://assets.myeikserver.com",
|
42
|
+
)
|
43
|
+
.example("eik map my-map 1.0.0 ./import-map.json --token yourtoken");
|
55
44
|
};
|
56
45
|
|
57
|
-
export const handler =
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
try {
|
62
|
-
const log = logger(spinner, debug);
|
46
|
+
export const handler = commandHandler(
|
47
|
+
{ command, options: ["server"] },
|
48
|
+
async (argv, log) => {
|
49
|
+
const { debug, name, version, server, ...rest } = argv;
|
63
50
|
|
64
|
-
await new PublishMap({
|
51
|
+
await new PublishMap({
|
52
|
+
logger: log,
|
53
|
+
debug,
|
54
|
+
name,
|
55
|
+
version,
|
56
|
+
server,
|
57
|
+
...rest,
|
58
|
+
}).run();
|
65
59
|
|
66
60
|
let url = new URL(join("map", name), server);
|
67
61
|
let res = await fetch(url);
|
@@ -72,19 +66,11 @@ export const handler = async (argv) => {
|
|
72
66
|
|
73
67
|
log.info(`Published import map "${name}" at version "${version}"`);
|
74
68
|
|
75
|
-
spinner.text = "";
|
76
|
-
spinner.stopAndPersist();
|
77
|
-
|
78
69
|
const artifact = new Artifact(pkgMeta);
|
79
70
|
const versions = new Map(pkgMeta.versions);
|
80
71
|
artifact.versions = Array.from(versions.values());
|
81
72
|
artifact.format(server);
|
82
73
|
|
83
74
|
process.stdout.write("\n");
|
84
|
-
}
|
85
|
-
|
86
|
-
spinner.text = "";
|
87
|
-
spinner.stopAndPersist();
|
88
|
-
process.exit(1);
|
89
|
-
}
|
90
|
-
};
|
75
|
+
},
|
76
|
+
);
|
package/commands/meta.js
CHANGED
@@ -1,59 +1,43 @@
|
|
1
|
-
import ora from "ora";
|
2
1
|
import Meta from "../classes/meta.js";
|
3
2
|
import { Artifact } from "../formatters/index.js";
|
4
|
-
import {
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
5
4
|
|
6
5
|
export const command = "meta <name>";
|
7
6
|
|
8
7
|
export const aliases = ["show"];
|
9
8
|
|
10
|
-
export const describe =
|
9
|
+
export const describe = "Get information about a package";
|
11
10
|
|
11
|
+
/** @type {import('yargs').CommandBuilder} */
|
12
12
|
export const builder = (yargs) => {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
});
|
28
|
-
|
29
|
-
yargs.example(`eik meta lit-html`);
|
30
|
-
yargs.example(`eik meta my-map --debug`);
|
31
|
-
yargs.example(`eik meta my-app --server https://assets.myeikserver.com`);
|
13
|
+
return yargs
|
14
|
+
.positional("name", {
|
15
|
+
describe: "Name matching one or more of package, npm or import map name",
|
16
|
+
type: "string",
|
17
|
+
})
|
18
|
+
.options({
|
19
|
+
server: {
|
20
|
+
alias: "s",
|
21
|
+
describe: "Eik server address, if different from configuration file",
|
22
|
+
},
|
23
|
+
})
|
24
|
+
.example("eik meta lit-html")
|
25
|
+
.example("eik meta my-map --debug")
|
26
|
+
.example("eik meta my-app --server https://assets.myeikserver.com");
|
32
27
|
};
|
33
28
|
|
34
|
-
export const handler =
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
spinner.text = "";
|
47
|
-
spinner.stopAndPersist();
|
48
|
-
l.warn(err.message);
|
49
|
-
process.exit(1);
|
50
|
-
}
|
51
|
-
|
52
|
-
if (meta) {
|
53
|
-
for (const m of Object.values(meta)) {
|
54
|
-
const artifact = new Artifact(m);
|
55
|
-
artifact.format(server);
|
56
|
-
process.stdout.write(`\n`);
|
29
|
+
export const handler = commandHandler(
|
30
|
+
{ command, options: ["server"] },
|
31
|
+
async (argv, log) => {
|
32
|
+
const { debug, server, ...rest } = argv;
|
33
|
+
|
34
|
+
const meta = await new Meta({ logger: log, debug, server, ...rest }).run();
|
35
|
+
if (meta) {
|
36
|
+
for (const m of Object.values(meta)) {
|
37
|
+
const artifact = new Artifact(m);
|
38
|
+
artifact.format(server);
|
39
|
+
process.stdout.write(`\n`);
|
40
|
+
}
|
57
41
|
}
|
58
|
-
}
|
59
|
-
|
42
|
+
},
|
43
|
+
);
|
package/commands/npm-alias.js
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
// @deprecated in favor of `alias` command
|
2
|
-
|
3
|
-
import ora from "ora";
|
4
1
|
import Alias from "../classes/alias.js";
|
5
|
-
import { logger, getDefaults } from "../utils/index.js";
|
6
2
|
import { Alias as AliasFormatter } from "../formatters/index.js";
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
7
4
|
|
8
5
|
export const command = "npm-alias <name> <version> <alias>";
|
9
6
|
|
10
7
|
export const aliases = ["na", "dep-alias", "dependency-alias"];
|
11
8
|
|
12
|
-
export const describe =
|
9
|
+
export const describe = "Create an alias for an NPM package";
|
13
10
|
|
14
|
-
export const
|
15
|
-
const defaults = getDefaults(yargs.argv.config || yargs.argv.cwd);
|
11
|
+
export const deprecated = "npm-alias has been replaced by alias";
|
16
12
|
|
17
|
-
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
14
|
+
export const builder = (yargs) => {
|
15
|
+
return yargs
|
18
16
|
.positional("name", {
|
19
17
|
describe: "Name matching NPM package name.",
|
20
18
|
type: "string",
|
@@ -27,64 +25,41 @@ export const builder = (yargs) => {
|
|
27
25
|
describe:
|
28
26
|
"Alias for a semver version. Must be the semver major component of version.",
|
29
27
|
type: "string",
|
30
|
-
})
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
alias
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
// @ts-expect-error
|
48
|
-
yargs.default("token", defaults.token, defaults.token ? "######" : "");
|
49
|
-
|
50
|
-
yargs.example(`eik npm lit-html 1.0.0 1`);
|
51
|
-
yargs.example(`eik npm lit-html 1.3.5 1 --debug`);
|
52
|
-
yargs.example(
|
53
|
-
`eik npm lit-html 5.3.2 5 --server https://assets.myeikserver.com`,
|
54
|
-
);
|
28
|
+
})
|
29
|
+
.options({
|
30
|
+
server: {
|
31
|
+
alias: "s",
|
32
|
+
describe: "Eik server address, if different from configuration file",
|
33
|
+
},
|
34
|
+
token: {
|
35
|
+
describe: "JWT used for authentication, if not using eik login",
|
36
|
+
alias: "t",
|
37
|
+
},
|
38
|
+
})
|
39
|
+
.example("eik npm-alias lit-html 1.0.0 1")
|
40
|
+
.example(
|
41
|
+
"eik npm-alias lit-html 5.3.2 5 --server https://assets.myeikserver.com",
|
42
|
+
)
|
43
|
+
.example("eik npm-alias lit-html 1.0.0 1 --token yourtoken");
|
55
44
|
};
|
56
45
|
|
57
|
-
export const handler =
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
const log = logger(spinner, debug);
|
62
|
-
let data = {};
|
46
|
+
export const handler = commandHandler(
|
47
|
+
{ command, options: ["server"] },
|
48
|
+
async (argv, log) => {
|
49
|
+
const { debug, server, ...rest } = argv;
|
63
50
|
|
64
|
-
|
65
|
-
|
51
|
+
const data = await new Alias({
|
52
|
+
debug,
|
53
|
+
server,
|
54
|
+
...rest,
|
66
55
|
type: "npm",
|
67
56
|
logger: log,
|
68
|
-
...argv,
|
69
57
|
}).run();
|
70
58
|
|
71
59
|
const createdOrUpdated = data.update ? "Updated" : "Created";
|
72
60
|
log.info(
|
73
61
|
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
74
62
|
);
|
75
|
-
success = true;
|
76
|
-
} catch (err) {
|
77
|
-
log.warn(err.message);
|
78
|
-
}
|
79
|
-
|
80
|
-
spinner.text = "";
|
81
|
-
spinner.stopAndPersist();
|
82
|
-
if (success) {
|
83
63
|
new AliasFormatter(data).format(server);
|
84
|
-
}
|
85
|
-
|
86
|
-
}
|
87
|
-
};
|
88
|
-
|
89
|
-
export const deprecated =
|
90
|
-
'"npm-alias" will be removed in a future version. Please use "alias" instead';
|
64
|
+
},
|
65
|
+
);
|
@@ -1,101 +1,70 @@
|
|
1
|
-
// @deprecated in favor of `alias` command
|
2
|
-
|
3
|
-
import ora from "ora";
|
4
|
-
import semver from "semver";
|
5
1
|
import Alias from "../classes/alias.js";
|
6
|
-
import { logger, getDefaults } from "../utils/index.js";
|
7
2
|
import { Alias as AliasFormatter } from "../formatters/index.js";
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
8
4
|
|
9
5
|
export const command = "package-alias [name] [version] [alias]";
|
10
6
|
|
11
7
|
export const aliases = ["pkg-alias", "pa"];
|
12
8
|
|
13
|
-
export const describe =
|
9
|
+
export const describe = "Create an alias for a package";
|
14
10
|
|
15
|
-
export const
|
16
|
-
const defaults = getDefaults(yargs.argv.config || yargs.argv.cwd);
|
11
|
+
export const deprecated = "package-alias has been replaced by alias";
|
17
12
|
|
18
|
-
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
14
|
+
export const builder = (yargs) => {
|
15
|
+
return yargs
|
19
16
|
.positional("name", {
|
20
17
|
describe: "Name matching existing name for a package on Eik server",
|
21
18
|
type: "string",
|
22
|
-
// @ts-expect-error
|
23
|
-
default: defaults.name,
|
24
19
|
})
|
25
20
|
.positional("version", {
|
26
21
|
describe: "Version matching existing version for a package on Eik server",
|
27
22
|
type: "string",
|
28
|
-
// @ts-expect-error
|
29
|
-
default: defaults.version,
|
30
23
|
})
|
31
24
|
.positional("alias", {
|
32
25
|
describe:
|
33
26
|
"Alias for a semver version. Must be the semver major component of version. Eg. 1.0.0 should be given as 1",
|
34
27
|
type: "string",
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
}
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
alias
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
// @ts-expect-error
|
55
|
-
yargs.default("token", defaults.token, defaults.token ? "######" : "");
|
56
|
-
|
57
|
-
yargs.example(`eik package-alias my-app 1.0.0 1`);
|
58
|
-
yargs.example(`eik package-alias my-app 1.7.3 1`);
|
59
|
-
yargs.example(`eik package-alias my-app 6.3.1 6`);
|
60
|
-
yargs.example(
|
61
|
-
`eik package-alias my-app 6.3.1 6 --server https://assets.myeikserver.com`,
|
62
|
-
);
|
63
|
-
yargs.example(`eik package-alias my-app 4.2.2 4 --debug`);
|
28
|
+
})
|
29
|
+
.options({
|
30
|
+
server: {
|
31
|
+
alias: "s",
|
32
|
+
describe: "Eik server address, if different from configuration file",
|
33
|
+
},
|
34
|
+
token: {
|
35
|
+
describe: "JWT used for authentication, if not using eik login",
|
36
|
+
alias: "t",
|
37
|
+
},
|
38
|
+
})
|
39
|
+
.example("eik package-alias my-app 1.0.0 1")
|
40
|
+
.example("eik package-alias my-app 1.7.3 1")
|
41
|
+
.example("eik package-alias my-app 6.3.1 6")
|
42
|
+
.example(
|
43
|
+
"eik package-alias my-app 6.3.1 6 --server https://assets.myeikserver.com",
|
44
|
+
)
|
45
|
+
.example("eik package-alias my-app 4.2.2 4 --token yourtoken");
|
64
46
|
};
|
65
47
|
|
66
|
-
export const handler =
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
const log = logger(spinner, debug);
|
71
|
-
let af;
|
48
|
+
export const handler = commandHandler(
|
49
|
+
{ command, options: ["server"] },
|
50
|
+
async (argv, log) => {
|
51
|
+
const { debug, server, ...rest } = argv;
|
72
52
|
|
73
|
-
try {
|
74
53
|
const data = await new Alias({
|
54
|
+
debug,
|
55
|
+
server,
|
56
|
+
...rest,
|
75
57
|
type: "pkg",
|
76
58
|
logger: log,
|
77
|
-
...argv,
|
78
59
|
}).run();
|
79
60
|
|
80
|
-
af = new AliasFormatter(data);
|
61
|
+
const af = new AliasFormatter(data);
|
81
62
|
|
82
63
|
const createdOrUpdated = data.update ? "Updated" : "Created";
|
83
64
|
log.info(
|
84
65
|
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
85
66
|
);
|
86
|
-
success = true;
|
87
|
-
} catch (err) {
|
88
|
-
log.warn(err.message);
|
89
|
-
}
|
90
|
-
|
91
|
-
spinner.text = "";
|
92
|
-
spinner.stopAndPersist();
|
93
|
-
if (success) {
|
94
|
-
af?.format(server);
|
95
|
-
} else {
|
96
|
-
process.exit(1);
|
97
|
-
}
|
98
|
-
};
|
99
67
|
|
100
|
-
|
101
|
-
|
68
|
+
af.format(server);
|
69
|
+
},
|
70
|
+
);
|
package/commands/ping.js
CHANGED
@@ -1,38 +1,27 @@
|
|
1
|
-
import ora from "ora";
|
2
1
|
import Ping from "../classes/ping.js";
|
3
|
-
import {
|
2
|
+
import { commandHandler } from "../utils/command-handler.js";
|
4
3
|
|
4
|
+
// TODO: replace positional argument with --server to be in line with other commands
|
5
5
|
export const command = "ping [server]";
|
6
6
|
|
7
7
|
export const aliases = [];
|
8
8
|
|
9
|
-
export const describe =
|
9
|
+
export const describe = "Check that the Eik server is responding";
|
10
10
|
|
11
|
+
/** @type {import('yargs').CommandBuilder} */
|
11
12
|
export const builder = (yargs) => {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
});
|
19
|
-
|
20
|
-
yargs.example(`eik ping`);
|
21
|
-
yargs.example(`eik ping http://assets.myeikserver.com`);
|
22
|
-
yargs.example(`eik ping http://assets.myeikserver.com --debug`);
|
13
|
+
return yargs
|
14
|
+
.positional("server", {
|
15
|
+
describe: "Specify location of Eik server to check against.",
|
16
|
+
})
|
17
|
+
.example("eik ping")
|
18
|
+
.example("eik ping http://assets.myeikserver.com");
|
23
19
|
};
|
24
20
|
|
25
|
-
export const handler =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
// @ts-expect-error
|
33
|
-
logger.warn(err.message);
|
34
|
-
}
|
35
|
-
|
36
|
-
spinner.text = "";
|
37
|
-
spinner.stopAndPersist();
|
38
|
-
};
|
21
|
+
export const handler = commandHandler(
|
22
|
+
{ command, options: ["server"] },
|
23
|
+
async (argv, logger) => {
|
24
|
+
const { server } = argv;
|
25
|
+
await new Ping({ logger, server }).run();
|
26
|
+
},
|
27
|
+
);
|