@eik/cli 3.1.3 → 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 +14 -0
- package/classes/alias.js +109 -119
- package/classes/index.js +58 -58
- package/classes/integrity.js +89 -97
- package/classes/login.js +47 -47
- package/classes/meta.js +75 -80
- package/classes/ping.js +53 -53
- package/classes/publish/map.js +90 -92
- package/classes/publish/package/index.js +130 -130
- package/classes/publish/package/tasks/check-bundle-sizes.js +19 -21
- package/classes/publish/package/tasks/check-if-already-published.js +67 -72
- package/classes/publish/package/tasks/cleanup.js +17 -17
- package/classes/publish/package/tasks/create-temp-directory.js +17 -17
- package/classes/publish/package/tasks/create-zip-file.js +60 -65
- package/classes/publish/package/tasks/dry-run.js +15 -15
- package/classes/publish/package/tasks/save-metafile.js +17 -17
- package/classes/publish/package/tasks/task.js +7 -7
- package/classes/publish/package/tasks/upload-files.js +52 -56
- package/classes/publish/package/tasks/validate-input.js +24 -24
- package/classes/version.js +152 -163
- package/commands/alias.js +61 -95
- package/commands/init.js +89 -109
- package/commands/integrity.js +42 -55
- package/commands/login.js +80 -101
- package/commands/map-alias.js +62 -82
- package/commands/map.js +69 -83
- package/commands/meta.js +36 -53
- package/commands/npm-alias.js +55 -80
- package/commands/package-alias.js +58 -90
- package/commands/ping.js +19 -30
- package/commands/publish.js +117 -127
- package/commands/version.js +87 -95
- package/formatters/alias.js +60 -63
- package/formatters/artifact.js +77 -77
- package/formatters/file.js +25 -25
- package/formatters/index.js +4 -4
- package/formatters/version.js +49 -51
- package/index.js +76 -72
- package/package.json +5 -4
- package/readme.md +1 -1
- package/types/classes/alias.d.ts +3 -3
- package/types/classes/integrity.d.ts +1 -1
- package/types/classes/login.d.ts +1 -1
- package/types/classes/meta.d.ts +1 -1
- package/types/classes/ping.d.ts +1 -1
- package/types/classes/publish/map.d.ts +1 -1
- package/types/classes/publish/package/index.d.ts +11 -11
- package/types/classes/publish/package/tasks/check-bundle-sizes.d.ts +1 -1
- package/types/classes/publish/package/tasks/check-if-already-published.d.ts +1 -1
- package/types/classes/publish/package/tasks/cleanup.d.ts +1 -1
- package/types/classes/publish/package/tasks/create-temp-directory.d.ts +1 -1
- package/types/classes/publish/package/tasks/create-zip-file.d.ts +1 -1
- package/types/classes/publish/package/tasks/dry-run.d.ts +1 -1
- package/types/classes/publish/package/tasks/save-metafile.d.ts +1 -1
- package/types/classes/publish/package/tasks/task.d.ts +1 -1
- package/types/classes/publish/package/tasks/upload-files.d.ts +1 -1
- package/types/classes/publish/package/tasks/validate-input.d.ts +1 -1
- package/types/classes/version.d.ts +3 -3
- package/types/utils/defaults.d.ts +22 -0
- package/types/utils/error.d.ts +19 -0
- package/types/utils/hash/index.d.ts +3 -3
- package/types/utils/http/index.d.ts +4 -4
- package/types/utils/index.d.ts +5 -5
- package/types/utils/json/index.d.ts +3 -3
- package/utils/command-handler.js +72 -0
- package/utils/defaults.js +79 -0
- package/utils/error.js +42 -0
- package/utils/hash/file.js +4 -4
- package/utils/hash/files.js +9 -9
- package/utils/hash/index.js +3 -3
- package/utils/http/index.js +4 -4
- package/utils/http/integrity.js +18 -18
- package/utils/http/latest-version.js +37 -37
- package/utils/http/request.js +42 -42
- package/utils/http/versions.js +20 -20
- package/utils/index.js +6 -5
- package/utils/json/index.js +3 -3
- package/utils/json/read.js +26 -26
- package/utils/json/write-eik.js +17 -17
- package/utils/json/write.js +26 -28
- package/utils/logger.js +43 -43
- package/utils/type-title.js +3 -3
- package/utils/url.js +2 -2
- package/commands/index.js +0 -27
package/commands/map-alias.js
CHANGED
@@ -1,95 +1,75 @@
|
|
1
|
-
|
1
|
+
import Alias from "../classes/alias.js";
|
2
|
+
import { Alias as AliasFormatter } from "../formatters/index.js";
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
2
4
|
|
3
|
-
|
4
|
-
import Alias from '../classes/alias.js';
|
5
|
-
import { logger, getDefaults } from '../utils/index.js';
|
6
|
-
import { Alias as AliasFormatter } from '../formatters/index.js';
|
5
|
+
export const command = "map-alias <name> <version> <alias>";
|
7
6
|
|
8
|
-
export const
|
7
|
+
export const aliases = ["ma"];
|
9
8
|
|
10
|
-
export const
|
9
|
+
export const describe = "Create an alias for a map";
|
11
10
|
|
12
|
-
export const
|
11
|
+
export const deprecated = "map-alias has been replaced by alias";
|
13
12
|
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
14
14
|
export const builder = (yargs) => {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
// @ts-expect-error
|
47
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
48
|
-
|
49
|
-
yargs.example(`eik map-alias my-map 1.0.0 1`);
|
50
|
-
yargs.example(`eik map-alias my-map 1.7.3 1`);
|
51
|
-
yargs.example(`eik map-alias my-map 6.3.1 6`);
|
52
|
-
yargs.example(
|
53
|
-
`eik map-alias my-map 6.3.1 6 --server https://assets.myeikserver.com`,
|
54
|
-
);
|
55
|
-
yargs.example(`eik map-alias my-map 4.2.2 4 --debug`);
|
15
|
+
return yargs
|
16
|
+
.positional("name", {
|
17
|
+
describe: "Import map package name",
|
18
|
+
type: "string",
|
19
|
+
})
|
20
|
+
.positional("version", {
|
21
|
+
describe: "Import map version",
|
22
|
+
type: "string",
|
23
|
+
})
|
24
|
+
.positional("alias", {
|
25
|
+
describe:
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
53
|
+
const data = await new Alias({
|
54
|
+
debug,
|
55
|
+
name,
|
56
|
+
version,
|
57
|
+
server,
|
58
|
+
...rest,
|
59
|
+
type: "map",
|
60
|
+
logger: log,
|
61
|
+
}).run();
|
71
62
|
|
72
|
-
|
73
|
-
|
74
|
-
|
63
|
+
data.name = name;
|
64
|
+
data.version = version;
|
65
|
+
data.files = [];
|
75
66
|
|
76
|
-
|
77
|
-
log.info(
|
78
|
-
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
79
|
-
);
|
80
|
-
success = true;
|
81
|
-
} catch (err) {
|
82
|
-
log.warn(err.message);
|
83
|
-
}
|
67
|
+
const createdOrUpdated = data.update ? "Updated" : "Created";
|
84
68
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
new AliasFormatter(data).format(server);
|
89
|
-
} else {
|
90
|
-
process.exit(1);
|
91
|
-
}
|
92
|
-
};
|
69
|
+
log.info(
|
70
|
+
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
71
|
+
);
|
93
72
|
|
94
|
-
|
95
|
-
|
73
|
+
new AliasFormatter(data).format(server);
|
74
|
+
},
|
75
|
+
);
|
package/commands/map.js
CHANGED
@@ -1,90 +1,76 @@
|
|
1
|
-
import { join } from
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import {
|
5
|
-
import { Artifact } from '../formatters/index.js';
|
1
|
+
import { join } from "path";
|
2
|
+
import PublishMap from "../classes/publish/map.js";
|
3
|
+
import { Artifact } from "../formatters/index.js";
|
4
|
+
import { commandHandler } from "../utils/command-handler.js";
|
6
5
|
|
7
|
-
export const command =
|
6
|
+
export const command = "map <name> <version> <file>";
|
8
7
|
|
9
|
-
export const aliases = [
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
);
|
14
|
+
return yargs
|
15
|
+
.positional("name", {
|
16
|
+
describe: "Import map name.",
|
17
|
+
type: "string",
|
18
|
+
})
|
19
|
+
.positional("version", {
|
20
|
+
describe: "Import map version.",
|
21
|
+
type: "string",
|
22
|
+
})
|
23
|
+
.positional("file", {
|
24
|
+
describe:
|
25
|
+
"Path to import map file on local disk relative to the current working directory.",
|
26
|
+
type: "string",
|
27
|
+
normalize: true,
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
process.exit(1);
|
89
|
-
}
|
90
|
-
};
|
46
|
+
export const handler = commandHandler(
|
47
|
+
{ command, options: ["server"] },
|
48
|
+
async (argv, log) => {
|
49
|
+
const { debug, name, version, server, ...rest } = argv;
|
50
|
+
|
51
|
+
await new PublishMap({
|
52
|
+
logger: log,
|
53
|
+
debug,
|
54
|
+
name,
|
55
|
+
version,
|
56
|
+
server,
|
57
|
+
...rest,
|
58
|
+
}).run();
|
59
|
+
|
60
|
+
let url = new URL(join("map", name), server);
|
61
|
+
let res = await fetch(url);
|
62
|
+
const pkgMeta = await res.json();
|
63
|
+
|
64
|
+
url = new URL(join("map", name, version), server);
|
65
|
+
res = await fetch(url);
|
66
|
+
|
67
|
+
log.info(`Published import map "${name}" at version "${version}"`);
|
68
|
+
|
69
|
+
const artifact = new Artifact(pkgMeta);
|
70
|
+
const versions = new Map(pkgMeta.versions);
|
71
|
+
artifact.versions = Array.from(versions.values());
|
72
|
+
artifact.format(server);
|
73
|
+
|
74
|
+
process.stdout.write("\n");
|
75
|
+
},
|
76
|
+
);
|
package/commands/meta.js
CHANGED
@@ -1,60 +1,43 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import { logger, getDefaults } from '../utils/index.js';
|
1
|
+
import Meta from "../classes/meta.js";
|
2
|
+
import { Artifact } from "../formatters/index.js";
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
5
4
|
|
6
|
-
export const command =
|
5
|
+
export const command = "meta <name>";
|
7
6
|
|
8
|
-
export const aliases = [
|
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
|
-
|
30
|
-
yargs.example(`eik meta lit-html`);
|
31
|
-
yargs.example(`eik meta my-map --debug`);
|
32
|
-
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");
|
33
27
|
};
|
34
28
|
|
35
|
-
export const handler =
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
process.exit(1);
|
51
|
-
}
|
52
|
-
|
53
|
-
if (meta) {
|
54
|
-
for (const m of Object.values(meta)) {
|
55
|
-
const artifact = new Artifact(m);
|
56
|
-
artifact.format(server);
|
57
|
-
process.stdout.write(`\n`);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
};
|
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
|
+
}
|
41
|
+
}
|
42
|
+
},
|
43
|
+
);
|
package/commands/npm-alias.js
CHANGED
@@ -1,90 +1,65 @@
|
|
1
|
-
|
1
|
+
import Alias from "../classes/alias.js";
|
2
|
+
import { Alias as AliasFormatter } from "../formatters/index.js";
|
3
|
+
import { commandHandler } from "../utils/command-handler.js";
|
2
4
|
|
3
|
-
|
4
|
-
import Alias from '../classes/alias.js';
|
5
|
-
import { logger, getDefaults } from '../utils/index.js';
|
6
|
-
import { Alias as AliasFormatter } from '../formatters/index.js';
|
5
|
+
export const command = "npm-alias <name> <version> <alias>";
|
7
6
|
|
8
|
-
export const
|
7
|
+
export const aliases = ["na", "dep-alias", "dependency-alias"];
|
9
8
|
|
10
|
-
export const
|
9
|
+
export const describe = "Create an alias for an NPM package";
|
11
10
|
|
12
|
-
export const
|
11
|
+
export const deprecated = "npm-alias has been replaced by alias";
|
13
12
|
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
14
14
|
export const builder = (yargs) => {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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 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
|
-
);
|
15
|
+
return yargs
|
16
|
+
.positional("name", {
|
17
|
+
describe: "Name matching NPM package name.",
|
18
|
+
type: "string",
|
19
|
+
})
|
20
|
+
.positional("version", {
|
21
|
+
describe: "Version matching NPM package version.",
|
22
|
+
type: "string",
|
23
|
+
})
|
24
|
+
.positional("alias", {
|
25
|
+
describe:
|
26
|
+
"Alias for a semver version. Must be the semver major component of 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 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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
const createdOrUpdated = data.update ? 'Updated' : 'Created';
|
72
|
-
log.info(
|
73
|
-
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
74
|
-
);
|
75
|
-
success = true;
|
76
|
-
} catch (err) {
|
77
|
-
log.warn(err.message);
|
78
|
-
}
|
79
|
-
|
80
|
-
spinner.text = '';
|
81
|
-
spinner.stopAndPersist();
|
82
|
-
if (success) {
|
83
|
-
new AliasFormatter(data).format(server);
|
84
|
-
} else {
|
85
|
-
process.exit(1);
|
86
|
-
}
|
87
|
-
};
|
51
|
+
const data = await new Alias({
|
52
|
+
debug,
|
53
|
+
server,
|
54
|
+
...rest,
|
55
|
+
type: "npm",
|
56
|
+
logger: log,
|
57
|
+
}).run();
|
88
58
|
|
89
|
-
|
90
|
-
|
59
|
+
const createdOrUpdated = data.update ? "Updated" : "Created";
|
60
|
+
log.info(
|
61
|
+
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
62
|
+
);
|
63
|
+
new AliasFormatter(data).format(server);
|
64
|
+
},
|
65
|
+
);
|