@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
@@ -1,102 +1,70 @@
|
|
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 semver from 'semver';
|
5
|
-
import Alias from '../classes/alias.js';
|
6
|
-
import { logger, getDefaults } from '../utils/index.js';
|
7
|
-
import { Alias as AliasFormatter } from '../formatters/index.js';
|
5
|
+
export const command = "package-alias [name] [version] [alias]";
|
8
6
|
|
9
|
-
export const
|
7
|
+
export const aliases = ["pkg-alias", "pa"];
|
10
8
|
|
11
|
-
export const
|
9
|
+
export const describe = "Create an alias for a package";
|
12
10
|
|
13
|
-
export const
|
11
|
+
export const deprecated = "package-alias has been replaced by alias";
|
14
12
|
|
13
|
+
/** @type {import('yargs').CommandBuilder} */
|
15
14
|
export const builder = (yargs) => {
|
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
|
-
token: {
|
48
|
-
describe:
|
49
|
-
'Provide a jwt token to be used to authenticate with the Eik server.',
|
50
|
-
default: '',
|
51
|
-
alias: 't',
|
52
|
-
},
|
53
|
-
});
|
54
|
-
|
55
|
-
// @ts-expect-error
|
56
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
57
|
-
|
58
|
-
yargs.example(`eik package-alias my-app 1.0.0 1`);
|
59
|
-
yargs.example(`eik package-alias my-app 1.7.3 1`);
|
60
|
-
yargs.example(`eik package-alias my-app 6.3.1 6`);
|
61
|
-
yargs.example(
|
62
|
-
`eik package-alias my-app 6.3.1 6 --server https://assets.myeikserver.com`,
|
63
|
-
);
|
64
|
-
yargs.example(`eik package-alias my-app 4.2.2 4 --debug`);
|
15
|
+
return yargs
|
16
|
+
.positional("name", {
|
17
|
+
describe: "Name matching existing name for a package on Eik server",
|
18
|
+
type: "string",
|
19
|
+
})
|
20
|
+
.positional("version", {
|
21
|
+
describe: "Version matching existing version for a package on Eik server",
|
22
|
+
type: "string",
|
23
|
+
})
|
24
|
+
.positional("alias", {
|
25
|
+
describe:
|
26
|
+
"Alias for a semver version. Must be the semver major component of version. Eg. 1.0.0 should be given as 1",
|
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 package-alias my-app 1.0.0 1")
|
40
|
+
.example("eik package-alias my-app 1.7.3 1")
|
41
|
+
.example("eik package-alias my-app 6.3.1 6")
|
42
|
+
.example(
|
43
|
+
"eik package-alias my-app 6.3.1 6 --server https://assets.myeikserver.com",
|
44
|
+
)
|
45
|
+
.example("eik package-alias my-app 4.2.2 4 --token yourtoken");
|
65
46
|
};
|
66
47
|
|
67
|
-
export const handler =
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
const log = logger(spinner, debug);
|
72
|
-
let af;
|
73
|
-
|
74
|
-
try {
|
75
|
-
const data = await new Alias({
|
76
|
-
type: 'pkg',
|
77
|
-
logger: log,
|
78
|
-
...argv,
|
79
|
-
}).run();
|
48
|
+
export const handler = commandHandler(
|
49
|
+
{ command, options: ["server"] },
|
50
|
+
async (argv, log) => {
|
51
|
+
const { debug, server, ...rest } = argv;
|
80
52
|
|
81
|
-
|
53
|
+
const data = await new Alias({
|
54
|
+
debug,
|
55
|
+
server,
|
56
|
+
...rest,
|
57
|
+
type: "pkg",
|
58
|
+
logger: log,
|
59
|
+
}).run();
|
82
60
|
|
83
|
-
|
84
|
-
log.info(
|
85
|
-
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
86
|
-
);
|
87
|
-
success = true;
|
88
|
-
} catch (err) {
|
89
|
-
log.warn(err.message);
|
90
|
-
}
|
61
|
+
const af = new AliasFormatter(data);
|
91
62
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
} else {
|
97
|
-
process.exit(1);
|
98
|
-
}
|
99
|
-
};
|
63
|
+
const createdOrUpdated = data.update ? "Updated" : "Created";
|
64
|
+
log.info(
|
65
|
+
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
66
|
+
);
|
100
67
|
|
101
|
-
|
102
|
-
|
68
|
+
af.format(server);
|
69
|
+
},
|
70
|
+
);
|
package/commands/ping.js
CHANGED
@@ -1,38 +1,27 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import { logger, getDefaults } from '../utils/index.js';
|
1
|
+
import Ping from "../classes/ping.js";
|
2
|
+
import { commandHandler } from "../utils/command-handler.js";
|
4
3
|
|
5
|
-
|
4
|
+
// TODO: replace positional argument with --server to be in line with other commands
|
5
|
+
export const command = "ping [server]";
|
6
6
|
|
7
7
|
export const aliases = [];
|
8
8
|
|
9
|
-
export const describe =
|
9
|
+
export const describe = "Check that the Eik server is responding";
|
10
10
|
|
11
|
+
/** @type {import('yargs').CommandBuilder} */
|
11
12
|
export const builder = (yargs) => {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
});
|
19
|
-
|
20
|
-
yargs.example(`eik ping`);
|
21
|
-
yargs.example(`eik ping http://assets.myeikserver.com`);
|
22
|
-
yargs.example(`eik ping http://assets.myeikserver.com --debug`);
|
13
|
+
return yargs
|
14
|
+
.positional("server", {
|
15
|
+
describe: "Specify location of Eik server to check against.",
|
16
|
+
})
|
17
|
+
.example("eik ping")
|
18
|
+
.example("eik ping http://assets.myeikserver.com");
|
23
19
|
};
|
24
20
|
|
25
|
-
export const handler =
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
// @ts-expect-error
|
33
|
-
logger.warn(err.message);
|
34
|
-
}
|
35
|
-
|
36
|
-
spinner.text = '';
|
37
|
-
spinner.stopAndPersist();
|
38
|
-
};
|
21
|
+
export const handler = commandHandler(
|
22
|
+
{ command, options: ["server"] },
|
23
|
+
async (argv, logger) => {
|
24
|
+
const { server } = argv;
|
25
|
+
await new Ping({ logger, server }).run();
|
26
|
+
},
|
27
|
+
);
|
package/commands/publish.js
CHANGED
@@ -1,134 +1,124 @@
|
|
1
|
-
import { join } from
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import {
|
6
|
-
import {
|
1
|
+
import { join } from "path";
|
2
|
+
import chalk from "chalk";
|
3
|
+
import PublishPackage from "../classes/publish/package/index.js";
|
4
|
+
import { typeSlug, typeTitle } from "../utils/index.js";
|
5
|
+
import { Artifact } from "../formatters/index.js";
|
6
|
+
import { EikCliError, errors } from "../utils/error.js";
|
7
|
+
import { commandHandler } from "../utils/command-handler.js";
|
7
8
|
|
8
|
-
export const command =
|
9
|
+
export const command = "publish";
|
9
10
|
|
10
|
-
export const aliases = [
|
11
|
+
export const aliases = ["pkg", "package", "pub"];
|
11
12
|
|
12
|
-
export const describe =
|
13
|
+
export const describe = "Publish an app package to an Eik server";
|
13
14
|
|
15
|
+
/** @type {import('yargs').CommandBuilder} */
|
14
16
|
export const builder = (yargs) => {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
// @ts-expect-error
|
33
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
34
|
-
|
35
|
-
yargs.example(`eik publish`);
|
36
|
-
yargs.example(`eik package`);
|
37
|
-
yargs.example(`eik pub --dry-run`);
|
38
|
-
yargs.example(`eik pkg --token ######`);
|
39
|
-
yargs.example(`eik pkg --debug`);
|
17
|
+
return yargs
|
18
|
+
.options({
|
19
|
+
dryRun: {
|
20
|
+
alias: "d",
|
21
|
+
describe: "Log details about the operation and skip upload",
|
22
|
+
type: "boolean",
|
23
|
+
},
|
24
|
+
token: {
|
25
|
+
describe: "JWT used for authentication, if not using eik login",
|
26
|
+
type: "string",
|
27
|
+
alias: "t",
|
28
|
+
},
|
29
|
+
})
|
30
|
+
.example("eik publish")
|
31
|
+
.example("eik publish --dry-run")
|
32
|
+
.example("eik publish --token yourtoken");
|
40
33
|
};
|
41
34
|
|
42
|
-
export const handler =
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
process.exit(1);
|
133
|
-
}
|
134
|
-
};
|
35
|
+
export const handler = commandHandler(
|
36
|
+
{ command, options: ["server"] },
|
37
|
+
async (argv, log, spinner) => {
|
38
|
+
const {
|
39
|
+
debug,
|
40
|
+
dryRun,
|
41
|
+
cwd,
|
42
|
+
token,
|
43
|
+
name,
|
44
|
+
version,
|
45
|
+
server,
|
46
|
+
map,
|
47
|
+
out,
|
48
|
+
files,
|
49
|
+
type,
|
50
|
+
} = argv;
|
51
|
+
|
52
|
+
if (type === "map") {
|
53
|
+
throw new EikCliError(
|
54
|
+
errors.ERR_WRONG_TYPE,
|
55
|
+
'"type" is set to "map", which is not supported by the publish command. Please use the "eik map" command instead',
|
56
|
+
);
|
57
|
+
}
|
58
|
+
|
59
|
+
const options = {
|
60
|
+
logger: log,
|
61
|
+
cwd,
|
62
|
+
token,
|
63
|
+
dryRun,
|
64
|
+
debug,
|
65
|
+
name,
|
66
|
+
server,
|
67
|
+
version,
|
68
|
+
type,
|
69
|
+
map,
|
70
|
+
out,
|
71
|
+
files,
|
72
|
+
};
|
73
|
+
|
74
|
+
const publish = await new PublishPackage(options).run();
|
75
|
+
|
76
|
+
if (!publish) {
|
77
|
+
throw new EikCliError(
|
78
|
+
errors.ERR_VERSION_EXISTS,
|
79
|
+
"Version in eik.json has not changed since last publish, publishing is not necessary",
|
80
|
+
);
|
81
|
+
}
|
82
|
+
|
83
|
+
const { files: fls } = publish;
|
84
|
+
|
85
|
+
if (!dryRun) {
|
86
|
+
let url = new URL(join(typeSlug(type), name), server);
|
87
|
+
let res = await fetch(url);
|
88
|
+
const pkgMeta = await res.json();
|
89
|
+
|
90
|
+
url = new URL(join(typeSlug(type), name, version), server);
|
91
|
+
res = await fetch(url);
|
92
|
+
const pkgVersionMeta = await res.json();
|
93
|
+
|
94
|
+
const artifact = new Artifact(pkgMeta);
|
95
|
+
artifact.versions = [pkgVersionMeta];
|
96
|
+
|
97
|
+
spinner.text = "";
|
98
|
+
spinner.stopAndPersist();
|
99
|
+
|
100
|
+
artifact.format(server);
|
101
|
+
process.stdout.write("\n");
|
102
|
+
} else {
|
103
|
+
spinner.text = "";
|
104
|
+
spinner.stopAndPersist();
|
105
|
+
|
106
|
+
process.stdout.write(
|
107
|
+
`:: ${chalk.bgYellow.white.bold(
|
108
|
+
typeTitle(type),
|
109
|
+
)} > ${chalk.green(name)} | ${chalk.bold("dry run")}`,
|
110
|
+
);
|
111
|
+
process.stdout.write("\n\n");
|
112
|
+
process.stdout.write(" files (local temporary):\n");
|
113
|
+
for (const file of fls) {
|
114
|
+
process.stdout.write(` - ${chalk.bold("type")}: ${file.type}\n`);
|
115
|
+
process.stdout.write(
|
116
|
+
` ${chalk.bold("path")}: ${file.pathname}\n\n`,
|
117
|
+
);
|
118
|
+
}
|
119
|
+
process.stdout.write(
|
120
|
+
` ${chalk.bold("No files were published to remote server")}\n\n`,
|
121
|
+
);
|
122
|
+
}
|
123
|
+
},
|
124
|
+
);
|