@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/version.js
CHANGED
@@ -1,107 +1,99 @@
|
|
1
|
-
import { execSync } from
|
2
|
-
import { join } from
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import {
|
6
|
-
import
|
1
|
+
import { execSync } from "child_process";
|
2
|
+
import { join } from "path";
|
3
|
+
import VersionPackage from "../classes/version.js";
|
4
|
+
import json from "../utils/json/index.js";
|
5
|
+
import { EikCliError, errors } from "../utils/error.js";
|
6
|
+
import { commandHandler } from "../utils/command-handler.js";
|
7
7
|
|
8
|
-
export const command =
|
8
|
+
export const command = "version [level]";
|
9
9
|
|
10
|
-
export const describe =
|
10
|
+
export const describe =
|
11
|
+
'Compare local files with files on server and increment "version" field if different';
|
11
12
|
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
12
14
|
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 version`);
|
31
|
-
yargs.example(`eik version minor`);
|
15
|
+
return yargs
|
16
|
+
.positional("level", {
|
17
|
+
describe: "Semver level to increment version by",
|
18
|
+
default: "patch",
|
19
|
+
type: "string",
|
20
|
+
choices: ["major", "minor", "patch"],
|
21
|
+
})
|
22
|
+
.options({
|
23
|
+
dryRun: {
|
24
|
+
alias: "d",
|
25
|
+
describe: "Log details about the operation and skip upload",
|
26
|
+
type: "boolean",
|
27
|
+
},
|
28
|
+
})
|
29
|
+
.example("eik version")
|
30
|
+
.example("eik version minor")
|
31
|
+
.example("eik version --dry-run");
|
32
32
|
};
|
33
33
|
|
34
|
-
export const handler =
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
const { name, version, server, map, out, files } = getDefaults(
|
39
|
-
config || cwd,
|
40
|
-
);
|
41
|
-
|
42
|
-
try {
|
43
|
-
const log = logger(spinner, debug);
|
34
|
+
export const handler = commandHandler(
|
35
|
+
{ command, options: ["server"] },
|
36
|
+
async (argv, log) => {
|
37
|
+
const { level, dryRun, cwd, name, version, server, map, out, files } = argv;
|
44
38
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
39
|
+
const options = {
|
40
|
+
logger: log,
|
41
|
+
name,
|
42
|
+
server,
|
43
|
+
version,
|
44
|
+
cwd,
|
45
|
+
level,
|
46
|
+
map,
|
47
|
+
out,
|
48
|
+
files,
|
49
|
+
};
|
56
50
|
|
57
|
-
|
51
|
+
const newVersion = await new VersionPackage(options).run();
|
58
52
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
53
|
+
if (dryRun) {
|
54
|
+
log.info(
|
55
|
+
`Dry Run: new version needed, determined new version to be ${newVersion}`,
|
56
|
+
);
|
57
|
+
} else {
|
58
|
+
log.debug(`Writing new version ${newVersion} to eik.json`);
|
59
|
+
// @ts-expect-error
|
60
|
+
await json.writeEik({ version: newVersion }, { cwd });
|
67
61
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
62
|
+
log.debug(`Committing eik.json to local git repository`);
|
63
|
+
try {
|
64
|
+
execSync(`git add ${join(cwd, "eik.json")}`);
|
65
|
+
log.debug(` ==> stage: ${join(cwd, "eik.json")}`);
|
66
|
+
} catch (err) {
|
67
|
+
throw new EikCliError(
|
68
|
+
errors.ERR_NOT_GIT,
|
69
|
+
'Failed to stage file "eik.json". Is this directory (or any parent directories) a git repository?',
|
70
|
+
err,
|
71
|
+
);
|
72
|
+
}
|
77
73
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
74
|
+
try {
|
75
|
+
execSync(
|
76
|
+
`git commit -m "build(assets): version eik.json to v${newVersion} [skip ci]"`,
|
77
|
+
{
|
78
|
+
env: {
|
79
|
+
GIT_AUTHOR_NAME: "Eik Cli",
|
80
|
+
GIT_AUTHOR_EMAIL: "eik@eik.dev",
|
81
|
+
GIT_COMMITTER_NAME: "Eik Cli",
|
82
|
+
GIT_COMMITTER_EMAIL: "eik@eik.dev",
|
83
|
+
},
|
84
|
+
stdio: "ignore",
|
85
|
+
},
|
86
|
+
);
|
87
|
+
log.debug(` ==> commit`);
|
92
88
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
spinner.text = '';
|
105
|
-
spinner.stopAndPersist();
|
106
|
-
}
|
107
|
-
};
|
89
|
+
log.info(`New version ${newVersion} written back to eik.json`);
|
90
|
+
} catch (err) {
|
91
|
+
throw new EikCliError(
|
92
|
+
errors.ERR_GIT_COMMIT,
|
93
|
+
'Failed to commit changes to file "eik.json".',
|
94
|
+
err,
|
95
|
+
);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
},
|
99
|
+
);
|
package/formatters/alias.js
CHANGED
@@ -1,82 +1,79 @@
|
|
1
|
-
import { join } from
|
2
|
-
import chalk from
|
3
|
-
import File from
|
1
|
+
import { join } from "path";
|
2
|
+
import chalk from "chalk";
|
3
|
+
import File from "./file.js";
|
4
4
|
|
5
5
|
function colorType(type) {
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
if (type === "npm") {
|
7
|
+
return chalk.white.bgRed.bold(" NPM ");
|
8
|
+
}
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if (type === "pkg") {
|
11
|
+
return chalk.white.bgYellow.bold(" PACKAGE ");
|
12
|
+
}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
if (type === "img") {
|
15
|
+
return chalk.white.bgYellow.bold(" IMAGE ");
|
16
|
+
}
|
17
17
|
|
18
|
-
|
18
|
+
return chalk.white.bgBlue.bold(" IMPORT MAP ");
|
19
19
|
}
|
20
20
|
|
21
21
|
class Alias {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
constructor({
|
23
|
+
type = "",
|
24
|
+
name = "",
|
25
|
+
alias = "",
|
26
|
+
version = "",
|
27
|
+
update = false,
|
28
|
+
files = [],
|
29
|
+
org = "",
|
30
|
+
integrity = "",
|
31
|
+
} = {}) {
|
32
|
+
this.type = type;
|
33
|
+
this.name = name;
|
34
|
+
this.org = org;
|
35
|
+
this.alias = alias;
|
36
|
+
this.version = version;
|
37
|
+
this.files = files;
|
38
|
+
this.update = update;
|
39
|
+
this.integrity = integrity;
|
40
|
+
}
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
join(this.type, this.name, `v${this.alias}`),
|
46
|
-
baseURL,
|
47
|
-
);
|
42
|
+
format(baseURL = "") {
|
43
|
+
const write = process.stdout.write.bind(process.stdout);
|
44
|
+
const url = new URL(join(this.type, this.name, `v${this.alias}`), baseURL);
|
48
45
|
|
49
|
-
|
46
|
+
write(`:: `);
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
48
|
+
write(`${colorType(this.type)} > ${chalk.green(this.name)} | `);
|
49
|
+
write(`${chalk.bold("org:")} ${this.org} | `);
|
50
|
+
write(`${chalk.bold("version:")} ${this.version} | `);
|
51
|
+
write(`${chalk.bold("alias:")} v${this.alias} `);
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
if (this.update) {
|
54
|
+
write(`${chalk.bgMagenta.white(" UPDATED \n\n")}`);
|
55
|
+
} else {
|
56
|
+
write(`${chalk.bgGreen.white(" NEW ")}\n\n`);
|
57
|
+
}
|
61
58
|
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
if (url.href) {
|
60
|
+
write(` ${chalk.bold("url: ")} ${chalk.cyan(url.href)}\n`);
|
61
|
+
}
|
65
62
|
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
if (this.integrity) {
|
64
|
+
write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
|
65
|
+
}
|
69
66
|
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
if (this.files.length) {
|
68
|
+
write(`\n ${chalk.bold("files:")}\n`);
|
69
|
+
}
|
73
70
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
71
|
+
for (const file of this.files) {
|
72
|
+
new File(file).format(url.href);
|
73
|
+
write(`\n`);
|
74
|
+
}
|
75
|
+
write(`\n`);
|
76
|
+
}
|
80
77
|
}
|
81
78
|
|
82
79
|
export default Alias;
|
package/formatters/artifact.js
CHANGED
@@ -1,89 +1,89 @@
|
|
1
|
-
import { join } from
|
2
|
-
import chalk from
|
3
|
-
import Version from
|
1
|
+
import { join } from "path";
|
2
|
+
import chalk from "chalk";
|
3
|
+
import Version from "./version.js";
|
4
4
|
|
5
|
-
const _name = Symbol(
|
6
|
-
const _type = Symbol(
|
7
|
-
const _org = Symbol(
|
8
|
-
const _versions = Symbol(
|
5
|
+
const _name = Symbol("name");
|
6
|
+
const _type = Symbol("type");
|
7
|
+
const _org = Symbol("org");
|
8
|
+
const _versions = Symbol("versions");
|
9
9
|
|
10
10
|
function colorType(type) {
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
if (type === "npm") {
|
12
|
+
return chalk.white.bgRed.bold(" NPM ");
|
13
|
+
}
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
if (type === "pkg") {
|
16
|
+
return chalk.white.bgYellow.bold(" PACKAGE ");
|
17
|
+
}
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
if (type === "img") {
|
20
|
+
return chalk.white.bgYellow.bold(" IMAGE ");
|
21
|
+
}
|
22
22
|
|
23
|
-
|
23
|
+
return chalk.white.bgBlue.bold(" IMPORT MAP ");
|
24
24
|
}
|
25
25
|
|
26
26
|
class Artifact {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
27
|
+
constructor({ type = "", name = "", org = "", versions = [] } = {}) {
|
28
|
+
this.type = type;
|
29
|
+
this.name = name;
|
30
|
+
this.org = org;
|
31
|
+
this.versions = versions;
|
32
|
+
}
|
33
|
+
|
34
|
+
get type() {
|
35
|
+
return this[_type];
|
36
|
+
}
|
37
|
+
|
38
|
+
set type(type) {
|
39
|
+
this[_type] = type;
|
40
|
+
}
|
41
|
+
|
42
|
+
get name() {
|
43
|
+
return this[_name];
|
44
|
+
}
|
45
|
+
|
46
|
+
set name(name) {
|
47
|
+
this[_name] = name;
|
48
|
+
}
|
49
|
+
|
50
|
+
get org() {
|
51
|
+
return this[_org];
|
52
|
+
}
|
53
|
+
|
54
|
+
set org(org) {
|
55
|
+
this[_org] = org;
|
56
|
+
}
|
57
|
+
|
58
|
+
get versions() {
|
59
|
+
return this[_versions];
|
60
|
+
}
|
61
|
+
|
62
|
+
set versions(versions) {
|
63
|
+
const v = [];
|
64
|
+
for (const version of versions) {
|
65
|
+
v.push(new Version(version, this.baseURL));
|
66
|
+
}
|
67
|
+
this[_versions] = v;
|
68
|
+
}
|
69
|
+
|
70
|
+
format(baseURL = "") {
|
71
|
+
const write = process.stdout.write.bind(process.stdout);
|
72
|
+
const url = new URL(join(this.type, this.name), baseURL);
|
73
|
+
|
74
|
+
write(`:: ${colorType(this.type)} > ${chalk.green(this.name)} | `);
|
75
|
+
write(`${chalk.bold("org:")} ${this.org} | `);
|
76
|
+
write(`${chalk.bold("url:")} ${chalk.cyan(url.href)}\n`);
|
77
|
+
|
78
|
+
if (this.versions.length) {
|
79
|
+
write(`\n ${chalk.bold("versions:")}\n`);
|
80
|
+
}
|
81
|
+
|
82
|
+
for (const version of this.versions) {
|
83
|
+
version.format(url.href);
|
84
|
+
write(`\n`);
|
85
|
+
}
|
86
|
+
}
|
87
87
|
}
|
88
88
|
|
89
89
|
export default Artifact;
|
package/formatters/file.js
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
import { join } from
|
2
|
-
import chalk from
|
1
|
+
import { join } from "path";
|
2
|
+
import chalk from "chalk";
|
3
3
|
|
4
4
|
function readableBytes(bytes) {
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024)),
|
6
|
+
sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
7
|
+
return (bytes / 1024 ** i).toFixed(2) * 1 + " " + sizes[i];
|
8
8
|
}
|
9
9
|
|
10
10
|
class File {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
constructor({
|
12
|
+
pathname = "",
|
13
|
+
mimeType = "",
|
14
|
+
size = null,
|
15
|
+
integrity = "",
|
16
|
+
} = {}) {
|
17
|
+
this.pathname = pathname;
|
18
|
+
this.mimeType = mimeType;
|
19
|
+
this.size = size;
|
20
|
+
this.integrity = integrity;
|
21
|
+
}
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
format(baseURL = "") {
|
24
|
+
const write = process.stdout.write.bind(process.stdout);
|
25
|
+
const url = new URL(baseURL);
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
const fileUrl = new URL(join(url.pathname, this.pathname), url.origin);
|
28
|
+
write(` - ${chalk.cyan(fileUrl.href)} `);
|
29
|
+
write(`${chalk.yellow(this.mimeType)} `);
|
30
|
+
write(`${chalk.magenta(readableBytes(this.size))}\n`);
|
31
|
+
write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
|
32
|
+
}
|
33
33
|
}
|
34
34
|
|
35
35
|
export default File;
|
package/formatters/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import Artifact from
|
2
|
-
import Alias from
|
3
|
-
import File from
|
4
|
-
import Version from
|
1
|
+
import Artifact from "./artifact.js";
|
2
|
+
import Alias from "./alias.js";
|
3
|
+
import File from "./file.js";
|
4
|
+
import Version from "./version.js";
|
5
5
|
|
6
6
|
export { Artifact, Alias, Version, File };
|