@eik/cli 3.1.3 → 3.1.4
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 +108 -118
- 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 +87 -87
- package/commands/index.js +24 -24
- package/commands/init.js +98 -105
- package/commands/integrity.js +52 -52
- package/commands/login.js +96 -98
- package/commands/map-alias.js +73 -73
- package/commands/map.js +72 -72
- package/commands/meta.js +49 -50
- package/commands/npm-alias.js +69 -69
- package/commands/package-alias.js +79 -80
- package/commands/ping.js +25 -25
- package/commands/publish.js +120 -124
- package/commands/version.js +86 -88
- 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 +61 -61
- package/package.json +3 -2
- package/types/classes/alias.d.ts +1 -1
- 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/hash/index.d.ts +3 -3
- package/types/utils/http/index.d.ts +4 -4
- package/types/utils/index.d.ts +3 -3
- package/types/utils/json/index.d.ts +3 -3
- 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 +3 -3
- 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/version.js
CHANGED
@@ -1,107 +1,105 @@
|
|
1
|
-
import { execSync } from
|
2
|
-
import { join } from
|
3
|
-
import ora from
|
4
|
-
import VersionPackage from
|
5
|
-
import { logger, getDefaults } from
|
6
|
-
import json from
|
1
|
+
import { execSync } from "child_process";
|
2
|
+
import { join } from "path";
|
3
|
+
import ora from "ora";
|
4
|
+
import VersionPackage from "../classes/version.js";
|
5
|
+
import { logger, getDefaults } from "../utils/index.js";
|
6
|
+
import json from "../utils/json/index.js";
|
7
7
|
|
8
|
-
export const command =
|
8
|
+
export const command = "version [level]";
|
9
9
|
|
10
10
|
export const describe = `Compares local files with files on server and increments "version" field in eik.json if necessary.`;
|
11
11
|
|
12
12
|
export const builder = (yargs) => {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
yargs.positional("level", {
|
14
|
+
describe: "Semver level to increment version by",
|
15
|
+
default: "patch",
|
16
|
+
type: "string",
|
17
|
+
choices: ["major", "minor", "patch"],
|
18
|
+
});
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
yargs.options({
|
21
|
+
dryRun: {
|
22
|
+
alias: "d",
|
23
|
+
describe:
|
24
|
+
"Terminates the publish early (before upload) and provides information about created bundles for inspection.",
|
25
|
+
default: false,
|
26
|
+
type: "boolean",
|
27
|
+
},
|
28
|
+
});
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
yargs.example(`eik version`);
|
31
|
+
yargs.example(`eik version minor`);
|
32
32
|
};
|
33
33
|
|
34
34
|
export const handler = async (argv) => {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
config || cwd,
|
40
|
-
);
|
35
|
+
const spinner = ora({ stream: process.stdout }).start("working...");
|
36
|
+
const { level, debug, dryRun, cwd, config } = argv;
|
37
|
+
// @ts-expect-error
|
38
|
+
const { name, version, server, map, out, files } = getDefaults(config || cwd);
|
41
39
|
|
42
|
-
|
43
|
-
|
40
|
+
try {
|
41
|
+
const log = logger(spinner, debug);
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
const options = {
|
44
|
+
logger: log,
|
45
|
+
name,
|
46
|
+
server,
|
47
|
+
version,
|
48
|
+
cwd,
|
49
|
+
level,
|
50
|
+
map,
|
51
|
+
out,
|
52
|
+
files,
|
53
|
+
};
|
56
54
|
|
57
|
-
|
55
|
+
const newVersion = await new VersionPackage(options).run();
|
58
56
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
57
|
+
if (dryRun) {
|
58
|
+
log.info(
|
59
|
+
`Dry Run: new version needed, determined new version to be ${newVersion}`,
|
60
|
+
);
|
61
|
+
} else {
|
62
|
+
log.debug(`Writing new version ${newVersion} to eik.json`);
|
63
|
+
// @ts-expect-error
|
64
|
+
await json.writeEik({ version: newVersion }, { cwd });
|
67
65
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
66
|
+
log.debug(`Committing eik.json to local git repository`);
|
67
|
+
try {
|
68
|
+
execSync(`git add ${join(cwd, "eik.json")}`);
|
69
|
+
log.debug(` ==> stage: ${join(cwd, "eik.json")}`);
|
70
|
+
} catch (err) {
|
71
|
+
throw new Error(
|
72
|
+
'Failed to stage file "eik.json". Is this directory (or any parent directories) a git repository?',
|
73
|
+
);
|
74
|
+
}
|
77
75
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
76
|
+
try {
|
77
|
+
execSync(
|
78
|
+
`git commit -m "build(assets): version eik.json to v${newVersion} [skip ci]"`,
|
79
|
+
{
|
80
|
+
env: {
|
81
|
+
GIT_AUTHOR_NAME: "Eik Cli",
|
82
|
+
GIT_AUTHOR_EMAIL: "eik@eik.dev",
|
83
|
+
GIT_COMMITTER_NAME: "Eik Cli",
|
84
|
+
GIT_COMMITTER_EMAIL: "eik@eik.dev",
|
85
|
+
},
|
86
|
+
stdio: "ignore",
|
87
|
+
},
|
88
|
+
);
|
89
|
+
log.debug(` ==> commit`);
|
92
90
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
log.info(`New version ${newVersion} written back to eik.json`);
|
92
|
+
} catch (err) {
|
93
|
+
throw new Error('Failed to commit changes to file "eik.json".');
|
94
|
+
}
|
95
|
+
}
|
98
96
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
97
|
+
spinner.text = "";
|
98
|
+
spinner.stopAndPersist();
|
99
|
+
process.exit();
|
100
|
+
} catch (err) {
|
101
|
+
spinner.warn(err.message);
|
102
|
+
spinner.text = "";
|
103
|
+
spinner.stopAndPersist();
|
104
|
+
}
|
107
105
|
};
|
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 };
|