@eik/cli 3.1.2 → 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 +14 -0
- package/classes/alias.js +108 -114
- package/classes/index.js +58 -58
- package/classes/integrity.js +89 -97
- package/classes/login.js +47 -47
- package/classes/meta.js +75 -77
- package/classes/ping.js +53 -53
- package/classes/publish/map.js +90 -91
- 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 -13
- 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 +53 -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 +4 -7
- 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/types/utils/url.d.ts +6 -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 +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 +10 -0
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,39 +1,39 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import chalk from
|
3
|
-
import yargs from
|
4
|
-
import { hideBin } from
|
5
|
-
import boxen from
|
6
|
-
import { join } from
|
7
|
-
import { readFileSync } from
|
8
|
-
import { fileURLToPath } from
|
9
|
-
import { dirname } from
|
10
|
-
import { commands } from
|
2
|
+
import chalk from "chalk";
|
3
|
+
import yargs from "yargs";
|
4
|
+
import { hideBin } from "yargs/helpers";
|
5
|
+
import boxen from "boxen";
|
6
|
+
import { join } from "path";
|
7
|
+
import { readFileSync } from "fs";
|
8
|
+
import { fileURLToPath } from "url";
|
9
|
+
import { dirname } from "path";
|
10
|
+
import { commands } from "./commands/index.js";
|
11
11
|
|
12
12
|
const __filename = fileURLToPath(import.meta.url);
|
13
13
|
const __dirname = dirname(__filename);
|
14
14
|
|
15
15
|
const { version } = JSON.parse(
|
16
|
-
|
16
|
+
readFileSync(join(__dirname, "./package.json"), { encoding: "utf-8" }),
|
17
17
|
);
|
18
18
|
|
19
19
|
// short circuit and provide a -v and --version flag
|
20
20
|
if (
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
process.argv.includes("-v") ||
|
22
|
+
// last position only to avoid conflict with publish command
|
23
|
+
process.argv[process.argv.length - 1].includes("--version")
|
24
24
|
) {
|
25
|
-
|
26
|
-
|
25
|
+
console.log(version);
|
26
|
+
process.exit(0);
|
27
27
|
}
|
28
28
|
|
29
29
|
const greeting = chalk.white.bold(`Eik CLI (v${version})`);
|
30
30
|
|
31
31
|
const boxenOptions = {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
padding: 1,
|
33
|
+
margin: 1,
|
34
|
+
borderStyle: "round",
|
35
|
+
borderColor: "green",
|
36
|
+
backgroundColor: "#555555",
|
37
37
|
};
|
38
38
|
// @ts-expect-error
|
39
39
|
const msgBox = boxen(greeting, boxenOptions);
|
@@ -41,44 +41,44 @@ const msgBox = boxen(greeting, boxenOptions);
|
|
41
41
|
console.log(msgBox);
|
42
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
|
+
.options({
|
45
|
+
config: {
|
46
|
+
alias: "c",
|
47
|
+
describe:
|
48
|
+
"Provide an exact path to an eik.json or package.json file to use as config. Default is eik.json in the current working directory.",
|
49
|
+
},
|
50
|
+
cwd: {
|
51
|
+
describe: "Alter the current working directory.",
|
52
|
+
default: process.cwd(),
|
53
|
+
},
|
54
|
+
debug: {
|
55
|
+
describe: "Logs additional messages",
|
56
|
+
default: false,
|
57
|
+
type: "boolean",
|
58
|
+
},
|
59
|
+
})
|
60
|
+
// @ts-expect-error
|
61
|
+
.example("eik init")
|
62
|
+
// @ts-expect-error
|
63
|
+
.example("eik login --server https://assets.myserver.com --key ######")
|
64
|
+
// @ts-expect-error
|
65
|
+
.example("eik publish")
|
66
|
+
// @ts-expect-error
|
67
|
+
.example("eik meta my-app --server https://assets.myserver.com")
|
68
|
+
.example(
|
69
|
+
// @ts-expect-error
|
70
|
+
"eik npm-alias lit-html 1.0.0 1 --server https://assets.myserver.com --token ######",
|
71
|
+
)
|
72
|
+
.example(
|
73
|
+
// @ts-expect-error
|
74
|
+
"eik map my-map 1.0.0 ./import-map.json --server https://assets.myserver.com --token ######",
|
75
|
+
)
|
76
|
+
// @ts-expect-error
|
77
|
+
.example("eik map-alias my-map 1.0.0 1")
|
78
|
+
// @ts-expect-error
|
79
|
+
.command(commands)
|
80
|
+
.demandCommand()
|
81
|
+
.wrap(150)
|
82
|
+
.version(false)
|
83
|
+
.help()
|
84
|
+
.parse();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@eik/cli",
|
3
|
-
"version": "3.1.
|
3
|
+
"version": "3.1.4",
|
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",
|
@@ -25,10 +25,6 @@
|
|
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",
|
28
|
-
"test:ci:integration": "npm run test:integration -- --jobs=1",
|
29
|
-
"test:ci:unit": "npm run test:unit -- --jobs=1",
|
30
|
-
"test:ci:tasks": "npm run test:tasks -- --jobs=1",
|
31
|
-
"test:ci": "run-s test:ci:*",
|
32
28
|
"lint": "eslint .",
|
33
29
|
"lint:fix": "eslint --fix .",
|
34
30
|
"format:check": "prettier -c .",
|
@@ -51,7 +47,7 @@
|
|
51
47
|
"form-data": "4.0.0",
|
52
48
|
"gzip-size": "7.0.0",
|
53
49
|
"make-dir": "5.0.0",
|
54
|
-
"ora": "8.0
|
50
|
+
"ora": "8.1.0",
|
55
51
|
"rimraf": "6.0.1",
|
56
52
|
"semver": "7.6.3",
|
57
53
|
"ssri": "10.0.6",
|
@@ -61,8 +57,9 @@
|
|
61
57
|
},
|
62
58
|
"devDependencies": {
|
63
59
|
"@eik/eslint-config": "1.0.2",
|
60
|
+
"@eik/prettier-config": "1.0.1",
|
64
61
|
"@eik/semantic-release-config": "1.0.0",
|
65
|
-
"@eik/service": "2.3.
|
62
|
+
"@eik/service": "2.3.1",
|
66
63
|
"@eik/sink-memory": "1.1.2",
|
67
64
|
"@eik/typescript-config": "1.0.0",
|
68
65
|
"cross-env": "7.0.3",
|
package/types/classes/alias.d.ts
CHANGED
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";
|
@@ -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
|
1
|
+
import logger from "./logger.js";
|
2
2
|
export const getDefaults: typeof helpers.getDefaults;
|
3
3
|
export const typeSlug: typeof helpers.typeSlug;
|
4
|
-
import typeTitle from
|
5
|
-
import { helpers } from
|
4
|
+
import typeTitle from "./type-title.js";
|
5
|
+
import { helpers } from "@eik/common";
|
6
6
|
export { logger, 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";
|
package/utils/hash/file.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import ssri from
|
2
|
-
import fs from
|
1
|
+
import ssri from "ssri";
|
2
|
+
import fs from "fs";
|
3
3
|
|
4
4
|
/**
|
5
5
|
* Reads a file from a given path and produces and returns an integrity hash from its contents
|
@@ -11,6 +11,6 @@ import fs from 'fs';
|
|
11
11
|
* @example hash.file('/path/to/file.js');
|
12
12
|
*/
|
13
13
|
export default async (path) => {
|
14
|
-
|
15
|
-
|
14
|
+
const integrity = await ssri.fromStream(fs.createReadStream(path));
|
15
|
+
return integrity.toString();
|
16
16
|
};
|
package/utils/hash/files.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import ssri from
|
2
|
-
import fileHash from
|
1
|
+
import ssri from "ssri";
|
2
|
+
import fileHash from "./file.js";
|
3
3
|
|
4
4
|
/**
|
5
5
|
* Reads files from given paths and produces and returns an integrity hash from all files contents
|
@@ -11,11 +11,11 @@ import fileHash from './file.js';
|
|
11
11
|
* @example hash.files(['/path/to/file1.js', '/path/to/file2.js']);
|
12
12
|
*/
|
13
13
|
export default async (files) => {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
const hashes = await Promise.all(files.map(fileHash));
|
15
|
+
const hasher = ssri.create();
|
16
|
+
for (const hash of hashes.sort()) {
|
17
|
+
hasher.update(hash);
|
18
|
+
}
|
19
|
+
const integrity = hasher.digest();
|
20
|
+
return integrity.toString();
|
21
21
|
};
|
package/utils/hash/index.js
CHANGED
package/utils/http/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import latestVersion from
|
2
|
-
import versions from
|
3
|
-
import integrity from
|
4
|
-
import request from
|
1
|
+
import latestVersion from "./latest-version.js";
|
2
|
+
import versions from "./versions.js";
|
3
|
+
import integrity from "./integrity.js";
|
4
|
+
import request from "./request.js";
|
5
5
|
|
6
6
|
export default { latestVersion, versions, integrity, request };
|
7
7
|
export { latestVersion, versions, integrity, request };
|
package/utils/http/integrity.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { join } from
|
1
|
+
import { join } from "path";
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Fetches package integrity string by name and version from a given Eik asset server.
|
@@ -12,24 +12,24 @@ import { join } from 'path';
|
|
12
12
|
* @throws Error
|
13
13
|
*/
|
14
14
|
export default async (server, type, name, version) => {
|
15
|
-
|
16
|
-
|
15
|
+
const url = new URL(join(type, name, version), server);
|
16
|
+
url.search = `?t=${Date.now()}`;
|
17
17
|
|
18
|
-
|
18
|
+
const res = await fetch(url);
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
if (!res.ok) {
|
21
|
+
if (res.status === 404) {
|
22
|
+
return null;
|
23
|
+
}
|
24
|
+
throw new Error("Server responded with non 200 status code.");
|
25
|
+
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
try {
|
28
|
+
const body = await res.json();
|
29
|
+
return body.integrity;
|
30
|
+
} catch (err) {
|
31
|
+
throw new Error(
|
32
|
+
"An error occurred while attempting to parse json response from server.",
|
33
|
+
);
|
34
|
+
}
|
35
35
|
};
|