@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/formatters/version.js
CHANGED
@@ -1,61 +1,59 @@
|
|
1
|
-
import { join } from
|
2
|
-
import chalk from
|
3
|
-
import { formatDistance } from
|
4
|
-
import File from
|
1
|
+
import { join } from "path";
|
2
|
+
import chalk from "chalk";
|
3
|
+
import { formatDistance } from "date-fns/formatDistance";
|
4
|
+
import File from "./file.js";
|
5
5
|
|
6
6
|
class Version {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
7
|
+
constructor({
|
8
|
+
version = "",
|
9
|
+
integrity = "",
|
10
|
+
author = {},
|
11
|
+
created = null,
|
12
|
+
type = "",
|
13
|
+
name = "",
|
14
|
+
org = "",
|
15
|
+
files = [],
|
16
|
+
meta = [],
|
17
|
+
} = {}) {
|
18
|
+
this.version = version;
|
19
|
+
this.integrity = integrity;
|
20
|
+
this.author = author;
|
21
|
+
this.created = created;
|
22
|
+
this.type = type;
|
23
|
+
this.name = name;
|
24
|
+
this.org = org;
|
25
|
+
this.files = files;
|
26
|
+
this.meta = meta;
|
27
|
+
}
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
format(baseURL = "") {
|
30
|
+
const write = process.stdout.write.bind(process.stdout);
|
31
|
+
const url = new URL(baseURL);
|
32
|
+
const bURL = new URL(join(url.pathname, this.version), url.origin);
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
write(` - ${chalk.green(this.version)}\n`);
|
35
|
+
write(` ${chalk.bold("url:")} ${chalk.cyan(bURL.href)}\n`);
|
36
|
+
write(` ${chalk.bold("integrity:")} ${this.integrity}\n`);
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
if (this.files && this.files.length) {
|
39
|
+
write(`\n ${chalk.bold("files:")}\n`);
|
40
|
+
for (const file of this.files) {
|
41
|
+
new File(file).format(bURL.href);
|
42
|
+
write(`\n`);
|
43
|
+
}
|
44
|
+
}
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
write(` ${chalk.bold('published')} ${chalk.yellow(d)}`);
|
53
|
-
}
|
46
|
+
if (this.created) {
|
47
|
+
const d = formatDistance(new Date(this.created * 1000), new Date(), {
|
48
|
+
addSuffix: true,
|
49
|
+
});
|
50
|
+
write(` ${chalk.bold("published")} ${chalk.yellow(d)}`);
|
51
|
+
}
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
if (this.author && this.author.name) {
|
54
|
+
write(` ${chalk.bold("by")} ${chalk.yellow(this.author.name)}`);
|
55
|
+
}
|
56
|
+
}
|
59
57
|
}
|
60
58
|
|
61
59
|
export default Version;
|
package/index.js
CHANGED
@@ -1,84 +1,88 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import {
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
|
9
|
-
import
|
10
|
-
import
|
2
|
+
import yargs from "yargs";
|
3
|
+
import { hideBin } from "yargs/helpers";
|
4
|
+
import { join } from "path";
|
5
|
+
import { readFileSync } from "fs";
|
6
|
+
import { fileURLToPath } from "url";
|
7
|
+
import { dirname } from "path";
|
8
|
+
|
9
|
+
import * as alias from "./commands/alias.js";
|
10
|
+
import * as init from "./commands/init.js";
|
11
|
+
import * as integrity from "./commands/integrity.js";
|
12
|
+
import * as login from "./commands/login.js";
|
13
|
+
import * as mapAlias from "./commands/map-alias.js";
|
14
|
+
import * as map from "./commands/map.js";
|
15
|
+
import * as meta from "./commands/meta.js";
|
16
|
+
import * as npmAlias from "./commands/npm-alias.js";
|
17
|
+
import * as packageAlias from "./commands/package-alias.js";
|
18
|
+
import * as ping from "./commands/ping.js";
|
19
|
+
import * as publish from "./commands/publish.js";
|
20
|
+
import * as version from "./commands/version.js";
|
11
21
|
|
12
22
|
const __filename = fileURLToPath(import.meta.url);
|
13
23
|
const __dirname = dirname(__filename);
|
14
24
|
|
15
|
-
const { version } = JSON.parse(
|
16
|
-
|
25
|
+
const { version: cliVersion } = JSON.parse(
|
26
|
+
readFileSync(join(__dirname, "./package.json"), { encoding: "utf-8" }),
|
17
27
|
);
|
18
28
|
|
19
|
-
//
|
29
|
+
// Short circuit and provide a -v and --version flag.
|
30
|
+
// It's a known limitation in yargs that you can't have both a command
|
31
|
+
// and an option named version https://github.com/yargs/yargs/issues/2064
|
32
|
+
// We use the version name as a command in yargs, so handle the version
|
33
|
+
// option before using yargs.
|
20
34
|
if (
|
21
|
-
|
22
|
-
|
23
|
-
|
35
|
+
process.argv.includes("-v") ||
|
36
|
+
// last position only to avoid conflict with publish command
|
37
|
+
process.argv[process.argv.length - 1].includes("--version")
|
24
38
|
) {
|
25
|
-
|
26
|
-
|
39
|
+
console.log(cliVersion);
|
40
|
+
process.exit(0);
|
27
41
|
}
|
28
42
|
|
29
|
-
const greeting = chalk.white.bold(`Eik CLI (v${version})`);
|
30
|
-
|
31
|
-
const boxenOptions = {
|
32
|
-
padding: 1,
|
33
|
-
margin: 1,
|
34
|
-
borderStyle: 'round',
|
35
|
-
borderColor: 'green',
|
36
|
-
backgroundColor: '#555555',
|
37
|
-
};
|
38
|
-
// @ts-expect-error
|
39
|
-
const msgBox = boxen(greeting, boxenOptions);
|
40
|
-
|
41
|
-
console.log(msgBox);
|
42
|
-
|
43
43
|
yargs(hideBin(process.argv))
|
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
|
-
|
44
|
+
.scriptName("eik")
|
45
|
+
// inspired by git
|
46
|
+
.usage(
|
47
|
+
`usage: $0 [-v | --version] [-h | --help] [-c <path> | --config <path>]
|
48
|
+
[--cwd <path>] [--debug] <command> [<args>]`,
|
49
|
+
)
|
50
|
+
.epilogue(
|
51
|
+
`Run $0 <command> --help to read more about a specific subcommand.
|
52
|
+
|
53
|
+
For a more detailed description of commands and options, see the reference documentation:
|
54
|
+
https://eik.dev/cli`,
|
55
|
+
)
|
56
|
+
.options({
|
57
|
+
config: {
|
58
|
+
alias: "c",
|
59
|
+
describe: "Path to Eik configuration file (eik.json or package.json)",
|
60
|
+
},
|
61
|
+
cwd: {
|
62
|
+
describe: "Path to a different working directory than the current",
|
63
|
+
},
|
64
|
+
debug: {
|
65
|
+
describe: "Show additional logs",
|
66
|
+
type: "boolean",
|
67
|
+
},
|
68
|
+
})
|
69
|
+
.command([
|
70
|
+
alias,
|
71
|
+
init,
|
72
|
+
integrity,
|
73
|
+
login,
|
74
|
+
map,
|
75
|
+
mapAlias,
|
76
|
+
meta,
|
77
|
+
npmAlias,
|
78
|
+
packageAlias,
|
79
|
+
ping,
|
80
|
+
publish,
|
81
|
+
version,
|
82
|
+
])
|
83
|
+
.demandCommand()
|
84
|
+
.wrap(null)
|
85
|
+
.version(false) // Turn off the built-in version option to not conflict with the version command
|
86
|
+
.help()
|
87
|
+
.alias("h", "help")
|
88
|
+
.parse();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eik/cli",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.5",
|
4
4
|
"description": "CLI tool for publishing assets to an Eik server",
|
5
5
|
"main": "./classes/index.js",
|
6
6
|
"types": "./types/classes/index.d.ts",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
],
|
22
22
|
"scripts": {
|
23
23
|
"clean": "rimraf .tap node_modules types",
|
24
|
-
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage
|
24
|
+
"test": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage",
|
25
25
|
"test:integration": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage test/integration/**/*.test.mjs",
|
26
26
|
"test:unit": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage test/*.test.mjs",
|
27
27
|
"test:tasks": "cross-env HTTP_PORT=0 LOG_LEVEL=fatal tap --timeout 0 --disable-coverage test/tasks/*.test.mjs",
|
@@ -40,14 +40,13 @@
|
|
40
40
|
"dependencies": {
|
41
41
|
"@eik/common": "4.1.1",
|
42
42
|
"abslog": "2.4.4",
|
43
|
-
"boxen": "8.0.1",
|
44
43
|
"bytes": "3.1.2",
|
45
44
|
"chalk": "5.3.0",
|
46
45
|
"date-fns": "3.6.0",
|
47
46
|
"form-data": "4.0.0",
|
48
47
|
"gzip-size": "7.0.0",
|
49
48
|
"make-dir": "5.0.0",
|
50
|
-
"ora": "8.0
|
49
|
+
"ora": "8.1.0",
|
51
50
|
"rimraf": "6.0.1",
|
52
51
|
"semver": "7.6.3",
|
53
52
|
"ssri": "10.0.6",
|
@@ -57,10 +56,12 @@
|
|
57
56
|
},
|
58
57
|
"devDependencies": {
|
59
58
|
"@eik/eslint-config": "1.0.2",
|
59
|
+
"@eik/prettier-config": "1.0.1",
|
60
60
|
"@eik/semantic-release-config": "1.0.0",
|
61
61
|
"@eik/service": "2.3.1",
|
62
62
|
"@eik/sink-memory": "1.1.2",
|
63
63
|
"@eik/typescript-config": "1.0.0",
|
64
|
+
"@types/yargs": "17.0.33",
|
64
65
|
"cross-env": "7.0.3",
|
65
66
|
"eslint": "9.8.0",
|
66
67
|
"fastify": "4.28.1",
|
package/readme.md
CHANGED
package/types/classes/alias.d.ts
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @typedef {object} AliasOptions
|
3
3
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
4
4
|
* @property {string} server
|
5
|
-
* @property {"package" | "npm" | "map"} [type="package"]
|
5
|
+
* @property {"package" | "npm" | "image" | "map"} [type="package"]
|
6
6
|
* @property {string} name
|
7
7
|
* @property {string} version
|
8
8
|
* @property {string} alias
|
@@ -40,7 +40,7 @@ export default class Alias {
|
|
40
40
|
export type AliasOptions = {
|
41
41
|
logger?: import("abslog").AbstractLoggerOptions;
|
42
42
|
server: string;
|
43
|
-
type?: "package" | "npm" | "map";
|
43
|
+
type?: "package" | "npm" | "image" | "map";
|
44
44
|
name: string;
|
45
45
|
version: string;
|
46
46
|
alias: string;
|
@@ -57,4 +57,4 @@ export type AliasResult = {
|
|
57
57
|
org: string;
|
58
58
|
integrity: string;
|
59
59
|
};
|
60
|
-
import abslog from
|
60
|
+
import abslog from "abslog";
|
package/types/classes/login.d.ts
CHANGED
package/types/classes/meta.d.ts
CHANGED
package/types/classes/ping.d.ts
CHANGED
@@ -81,14 +81,14 @@ export type PublishResult = {
|
|
81
81
|
type: string;
|
82
82
|
}>;
|
83
83
|
};
|
84
|
-
import abslog from
|
85
|
-
import { EikConfig } from
|
86
|
-
import ValidateInput from
|
87
|
-
import CreateTempDirectory from
|
88
|
-
import CreateZipFile from
|
89
|
-
import CheckBundleSizes from
|
90
|
-
import DryRun from
|
91
|
-
import CheckIfAlreadyPublished from
|
92
|
-
import UploadFiles from
|
93
|
-
import SaveMetafile from
|
94
|
-
import Cleanup from
|
84
|
+
import abslog from "abslog";
|
85
|
+
import { EikConfig } from "@eik/common";
|
86
|
+
import ValidateInput from "./tasks/validate-input.js";
|
87
|
+
import CreateTempDirectory from "./tasks/create-temp-directory.js";
|
88
|
+
import CreateZipFile from "./tasks/create-zip-file.js";
|
89
|
+
import CheckBundleSizes from "./tasks/check-bundle-sizes.js";
|
90
|
+
import DryRun from "./tasks/dry-run.js";
|
91
|
+
import CheckIfAlreadyPublished from "./tasks/check-if-already-published.js";
|
92
|
+
import UploadFiles from "./tasks/upload-files.js";
|
93
|
+
import SaveMetafile from "./tasks/save-metafile.js";
|
94
|
+
import Cleanup from "./tasks/cleanup.js";
|
@@ -38,6 +38,6 @@ export type VersionOptions = {
|
|
38
38
|
out?: string;
|
39
39
|
files: string | Record<string, string>;
|
40
40
|
};
|
41
|
-
import abslog from
|
42
|
-
import { EikConfig } from
|
43
|
-
import semver from
|
41
|
+
import abslog from "abslog";
|
42
|
+
import { EikConfig } from "@eik/common";
|
43
|
+
import semver from "semver";
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Get defaults for things like server, name and version from Eik config.
|
3
|
+
* If a specific argument is given for it, that takes precedence.
|
4
|
+
* @template [T=Record<string, unknown>]
|
5
|
+
* @param {any} argv
|
6
|
+
* @param {{ command: string; options?: string[] }} opts
|
7
|
+
* @returns {import('@eik/common').EikConfig & typeof defaults & T}
|
8
|
+
*/
|
9
|
+
export function getArgsOrDefaults<T = Record<string, unknown>>(argv: any, opts: {
|
10
|
+
command: string;
|
11
|
+
options?: string[];
|
12
|
+
}): import("@eik/common").EikConfig & typeof defaults & T;
|
13
|
+
declare const defaults: {
|
14
|
+
name: string;
|
15
|
+
type: string;
|
16
|
+
version: string;
|
17
|
+
server: string;
|
18
|
+
out: string;
|
19
|
+
files: string;
|
20
|
+
"import-map": any[];
|
21
|
+
};
|
22
|
+
export {};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export namespace errors {
|
2
|
+
let ERR_MISSING_CONFIG: string;
|
3
|
+
let ERR_WRONG_TYPE: string;
|
4
|
+
let ERR_VERSION_EXISTS: string;
|
5
|
+
let ERR_NOT_GIT: string;
|
6
|
+
let ERR_GIT_COMMIT: string;
|
7
|
+
}
|
8
|
+
export class EikCliError extends Error {
|
9
|
+
/**
|
10
|
+
* @param {string} errorCode
|
11
|
+
* @param {string} message
|
12
|
+
* @param {Error} [cause]
|
13
|
+
*/
|
14
|
+
constructor(errorCode: string, message: string, cause?: Error);
|
15
|
+
cause: Error;
|
16
|
+
get errorCode(): string;
|
17
|
+
get exitCode(): number;
|
18
|
+
#private;
|
19
|
+
}
|
@@ -4,6 +4,6 @@ declare namespace _default {
|
|
4
4
|
export { compare };
|
5
5
|
}
|
6
6
|
export default _default;
|
7
|
-
import file from
|
8
|
-
import files from
|
9
|
-
import compare from
|
7
|
+
import file from "./file.js";
|
8
|
+
import files from "./files.js";
|
9
|
+
import compare from "./compare.js";
|
@@ -5,8 +5,8 @@ declare namespace _default {
|
|
5
5
|
export { request };
|
6
6
|
}
|
7
7
|
export default _default;
|
8
|
-
import latestVersion from
|
9
|
-
import versions from
|
10
|
-
import integrity from
|
11
|
-
import request from
|
8
|
+
import latestVersion from "./latest-version.js";
|
9
|
+
import versions from "./versions.js";
|
10
|
+
import integrity from "./integrity.js";
|
11
|
+
import request from "./request.js";
|
12
12
|
export { latestVersion, versions, integrity, request };
|
package/types/utils/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import logger from
|
2
|
-
|
1
|
+
import logger from "./logger.js";
|
2
|
+
import { getArgsOrDefaults } from "./defaults.js";
|
3
3
|
export const typeSlug: typeof helpers.typeSlug;
|
4
|
-
import typeTitle from
|
5
|
-
import { helpers } from
|
6
|
-
export { logger, typeTitle };
|
4
|
+
import typeTitle from "./type-title.js";
|
5
|
+
import { helpers } from "@eik/common";
|
6
|
+
export { logger, getArgsOrDefaults, typeTitle };
|
@@ -4,6 +4,6 @@ declare namespace _default {
|
|
4
4
|
export { writeEik };
|
5
5
|
}
|
6
6
|
export default _default;
|
7
|
-
import read from
|
8
|
-
import write from
|
9
|
-
import writeEik from
|
7
|
+
import read from "./read.js";
|
8
|
+
import write from "./write.js";
|
9
|
+
import writeEik from "./write-eik.js";
|