@eik/cli 2.0.21 → 3.0.0-next.2
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 +34 -0
- package/classes/alias.js +11 -8
- package/classes/integrity.js +10 -4
- package/classes/login.js +2 -2
- package/classes/meta.js +1 -1
- package/classes/ping.js +1 -1
- package/classes/publish/map.js +1 -1
- package/classes/publish/package/index.js +2 -2
- package/classes/publish/package/tasks/check-if-already-published.js +1 -1
- package/classes/publish/package/tasks/upload-files.js +5 -2
- package/classes/version.js +5 -2
- package/commands/alias.js +125 -0
- package/commands/integrity.js +2 -4
- package/commands/login.js +2 -1
- package/commands/meta.js +2 -1
- package/commands/ping.js +2 -1
- package/commands/publish.js +108 -74
- package/commands/version.js +2 -4
- package/formatters/alias.js +6 -0
- package/package.json +11 -8
- package/utils/index.js +1 -6
- package/commands/map-alias.js +0 -104
- package/commands/map.js +0 -104
- package/commands/npm-alias.js +0 -99
- package/commands/package-alias.js +0 -108
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
# [3.0.0-next.2](https://github.com/eik-lib/cli/compare/v3.0.0-next.1...v3.0.0-next.2) (2022-08-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* incorrect version number displayed on alias when updating with a cache layer infront ([8c468d6](https://github.com/eik-lib/cli/commit/8c468d670f6f10f25ae4decdab7a6950a1093d6a))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **!:** new alias command for all types of packages ([e482880](https://github.com/eik-lib/cli/commit/e48288002e9e8942f71d8f8dd0583395152aff49))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **!:** New alias command that is to be used for creating package, npm and import map aliases. Old alias commands have been removed.
|
|
17
|
+
|
|
18
|
+
# [3.0.0-next.1](https://github.com/eik-lib/cli/compare/v2.0.22...v3.0.0-next.1) (2022-08-17)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
* feat(publish)!: include map publishing in "publish" command ([7968274](https://github.com/eik-lib/cli/commit/796827442b28bb9852af63137275535fae737c21))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
* the map command has been removed in favour of a single publish command
|
|
27
|
+
|
|
28
|
+
## [2.0.22](https://github.com/eik-lib/cli/compare/v2.0.21...v2.0.22) (2022-01-28)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **deps:** update dependency bytes to v3.1.2 ([aa642b7](https://github.com/eik-lib/cli/commit/aa642b73fbce70633cda0bbe69ed503152980ed0))
|
|
34
|
+
|
|
1
35
|
## [2.0.21](https://github.com/eik-lib/cli/compare/v2.0.20...v2.0.21) (2022-01-16)
|
|
2
36
|
|
|
3
37
|
|
package/classes/alias.js
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
const abslog = require('abslog');
|
|
5
5
|
const { join } = require('path');
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
const validators = require('@eik/common-validators');
|
|
8
|
+
const schemas = require('@eik/common-schemas');
|
|
9
|
+
|
|
10
|
+
const { typeSlug } = require('@eik/common-utils');
|
|
7
11
|
const { request } = require('../utils/http');
|
|
8
|
-
const { typeSlug } = require('../utils');
|
|
9
12
|
|
|
10
13
|
module.exports = class Alias {
|
|
11
14
|
constructor({ logger, server, token, type, name, version, alias } = {}) {
|
|
@@ -56,7 +59,9 @@ module.exports = class Alias {
|
|
|
56
59
|
|
|
57
60
|
data.org = message.org || '';
|
|
58
61
|
data.integrity = message.integrity || '';
|
|
59
|
-
|
|
62
|
+
// We'll use message.version when the cache has been properly purged
|
|
63
|
+
// data.version = message.version || this.version;
|
|
64
|
+
data.version = this.version;
|
|
60
65
|
data.name = message.name || this.name;
|
|
61
66
|
data.files = message.files || [];
|
|
62
67
|
|
|
@@ -65,10 +70,6 @@ module.exports = class Alias {
|
|
|
65
70
|
let status = err.statusCode;
|
|
66
71
|
|
|
67
72
|
if (status === 409) {
|
|
68
|
-
this.log.debug(
|
|
69
|
-
'Alias already exists on server, performing update',
|
|
70
|
-
);
|
|
71
|
-
|
|
72
73
|
try {
|
|
73
74
|
const { message: msg } = await request({
|
|
74
75
|
host: this.server,
|
|
@@ -80,7 +81,9 @@ module.exports = class Alias {
|
|
|
80
81
|
|
|
81
82
|
data.org = msg.org || '';
|
|
82
83
|
data.integrity = msg.integrity || '';
|
|
83
|
-
|
|
84
|
+
// We'll use msg.version when the cache has been properly purged
|
|
85
|
+
// data.version = msg.version || this.version;
|
|
86
|
+
data.version = this.version;
|
|
84
87
|
data.name = msg.name || this.name;
|
|
85
88
|
data.files = msg.files || [];
|
|
86
89
|
data.update = true;
|
package/classes/integrity.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
const abslog = require('abslog');
|
|
7
7
|
const { join } = require('path');
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
const schemas = require('@eik/common-schemas');
|
|
10
|
+
|
|
11
|
+
const { typeSlug } = require('@eik/common-utils');
|
|
9
12
|
const fetch = require('node-fetch');
|
|
10
|
-
const { typeSlug } = require('../utils');
|
|
11
13
|
|
|
12
14
|
module.exports = class Integrity {
|
|
13
15
|
constructor({
|
|
@@ -46,12 +48,16 @@ module.exports = class Integrity {
|
|
|
46
48
|
|
|
47
49
|
this.log.debug(` ==> debug: ${this.debug}`);
|
|
48
50
|
if (typeof this.debug !== 'boolean') {
|
|
49
|
-
throw new ValidationError(
|
|
51
|
+
throw new schemas.ValidationError(
|
|
52
|
+
`Parameter "debug" is not valid`,
|
|
53
|
+
);
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
this.log.debug(` ==> cwd: ${this.cwd}`);
|
|
53
57
|
if (typeof this.cwd !== 'string') {
|
|
54
|
-
throw new ValidationError(
|
|
58
|
+
throw new schemas.ValidationError(
|
|
59
|
+
`Parameter "cwd" is not valid`,
|
|
60
|
+
);
|
|
55
61
|
}
|
|
56
62
|
} catch (err) {
|
|
57
63
|
throw new Error(
|
package/classes/login.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const abslog = require('abslog');
|
|
4
|
-
const
|
|
4
|
+
const schemas = require('@eik/common-schemas');
|
|
5
5
|
const { request } = require('../utils/http');
|
|
6
6
|
|
|
7
7
|
module.exports = class Login {
|
|
@@ -17,7 +17,7 @@ module.exports = class Login {
|
|
|
17
17
|
try {
|
|
18
18
|
schemas.assert.server(this.server);
|
|
19
19
|
if (!this.key || typeof !this.key === 'string') {
|
|
20
|
-
throw new ValidationError('"key" must be a string');
|
|
20
|
+
throw new schemas.ValidationError('"key" must be a string');
|
|
21
21
|
}
|
|
22
22
|
} catch (err) {
|
|
23
23
|
this.log.error(err.message);
|
package/classes/meta.js
CHANGED
package/classes/ping.js
CHANGED
package/classes/publish/map.js
CHANGED
|
@@ -4,7 +4,7 @@ const assert = require('assert');
|
|
|
4
4
|
const abslog = require('abslog');
|
|
5
5
|
const { join, parse, isAbsolute } = require('path');
|
|
6
6
|
const { existsSync } = require('fs');
|
|
7
|
-
const
|
|
7
|
+
const schemas = require('@eik/common-schemas');
|
|
8
8
|
const { request } = require('../../utils/http');
|
|
9
9
|
|
|
10
10
|
module.exports = class PublishMap {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const abslog = require('abslog');
|
|
4
4
|
const { join, isAbsolute } = require('path');
|
|
5
|
-
const { EikConfig } = require('@eik/common');
|
|
6
|
-
const { typeSlug } = require('
|
|
5
|
+
const { EikConfig } = require('@eik/common-config-loader');
|
|
6
|
+
const { typeSlug } = require('@eik/common-utils');
|
|
7
7
|
const ValidateInput = require('./tasks/validate-input');
|
|
8
8
|
const CreateTempDirectory = require('./tasks/create-temp-directory');
|
|
9
9
|
const CreateZipFile = require('./tasks/create-zip-file');
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
const { join } = require('path');
|
|
6
|
+
const { typeSlug } = require('@eik/common-utils');
|
|
6
7
|
const { integrity, versions } = require('../../../../utils/http');
|
|
7
8
|
const hash = require('../../../../utils/hash');
|
|
8
|
-
const { typeSlug } = require('../../../../utils');
|
|
9
9
|
const Task = require('./task');
|
|
10
10
|
|
|
11
11
|
module.exports = class CheckIfAlreadyPublished extends Task {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
const { join } = require('path');
|
|
6
|
+
const { typeSlug } = require('@eik/common-utils');
|
|
6
7
|
const { request } = require('../../../../utils/http');
|
|
7
|
-
const { typeSlug } = require('../../../../utils');
|
|
8
8
|
const Task = require('./task');
|
|
9
9
|
|
|
10
10
|
module.exports = class UploadFiles extends Task {
|
|
@@ -30,6 +30,7 @@ module.exports = class UploadFiles extends Task {
|
|
|
30
30
|
return message;
|
|
31
31
|
} catch (err) {
|
|
32
32
|
log.error('Unable to upload zip file to server');
|
|
33
|
+
|
|
33
34
|
switch (err.statusCode) {
|
|
34
35
|
case 400:
|
|
35
36
|
throw new Error(
|
|
@@ -52,7 +53,9 @@ module.exports = class UploadFiles extends Task {
|
|
|
52
53
|
'Server was unable to write file to storage',
|
|
53
54
|
);
|
|
54
55
|
default:
|
|
55
|
-
throw new Error(
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Upload to server failed, server responded with: ${err.message}`,
|
|
58
|
+
);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
}
|
package/classes/version.js
CHANGED
|
@@ -7,10 +7,13 @@ const { join, isAbsolute, parse } = require('path');
|
|
|
7
7
|
const abslog = require('abslog');
|
|
8
8
|
const semver = require('semver');
|
|
9
9
|
const mkdir = require('make-dir');
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
const { EikConfig } = require('@eik/common-config-loader');
|
|
12
|
+
const schemas = require('@eik/common-schemas');
|
|
13
|
+
|
|
14
|
+
const { typeSlug } = require('@eik/common-utils');
|
|
11
15
|
const { integrity } = require('../utils/http');
|
|
12
16
|
const hash = require('../utils/hash');
|
|
13
|
-
const { typeSlug } = require('../utils');
|
|
14
17
|
|
|
15
18
|
module.exports = class Version {
|
|
16
19
|
constructor({
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
2
|
+
const ora = require('ora');
|
|
3
|
+
const { configStore, getDefaults } = require('@eik/common-config-loader');
|
|
4
|
+
const { getCWD, logger } = require('../utils');
|
|
5
|
+
|
|
6
|
+
const Alias = require('../classes/alias');
|
|
7
|
+
const { Alias: AliasFormatter } = require('../formatters');
|
|
8
|
+
|
|
9
|
+
exports.command = 'alias <name> <version> <alias>';
|
|
10
|
+
|
|
11
|
+
exports.aliases = [
|
|
12
|
+
'ma',
|
|
13
|
+
'pa',
|
|
14
|
+
'pkg-alias',
|
|
15
|
+
'na',
|
|
16
|
+
'dep-alias',
|
|
17
|
+
'dependency-alias',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
exports.describe = `Create a semver major alias for a package or an import map as identified by its name and version.
|
|
21
|
+
A package or import map with the given name and version must already exist on the Eik server
|
|
22
|
+
Alias should be the semver major part of the version.
|
|
23
|
+
Eg. For a package or import map of version 5.4.3, you should use 5 as the alias`;
|
|
24
|
+
|
|
25
|
+
exports.builder = (yargs) => {
|
|
26
|
+
const cwd = getCWD();
|
|
27
|
+
const defaults = getDefaults(cwd);
|
|
28
|
+
|
|
29
|
+
yargs
|
|
30
|
+
.positional('name', {
|
|
31
|
+
describe: `Name of package or map that is to be aliased`,
|
|
32
|
+
type: 'string',
|
|
33
|
+
})
|
|
34
|
+
.positional('version', {
|
|
35
|
+
describe: `Version for package or map that is to be aliased`,
|
|
36
|
+
type: 'string',
|
|
37
|
+
})
|
|
38
|
+
.positional('alias', {
|
|
39
|
+
describe: `Alias for a semver version. Should be the semver major component of version.`,
|
|
40
|
+
type: 'string',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
yargs.options({
|
|
44
|
+
server: {
|
|
45
|
+
alias: 's',
|
|
46
|
+
describe: 'Specify location of Eik server.',
|
|
47
|
+
default: defaults.server,
|
|
48
|
+
},
|
|
49
|
+
cwd: {
|
|
50
|
+
alias: 'c',
|
|
51
|
+
describe: 'Alter current working directory.',
|
|
52
|
+
default: defaults.cwd,
|
|
53
|
+
},
|
|
54
|
+
debug: {
|
|
55
|
+
describe: 'Log additional messages',
|
|
56
|
+
default: false,
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
},
|
|
59
|
+
token: {
|
|
60
|
+
describe:
|
|
61
|
+
'Provide a jwt token to be used to authenticate with the Eik server.',
|
|
62
|
+
default: '',
|
|
63
|
+
alias: 't',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
|
68
|
+
|
|
69
|
+
yargs.example(`eik alias my-app 1.6.2 1`);
|
|
70
|
+
yargs.example(`eik alias my-map 1.0.1 1`);
|
|
71
|
+
yargs.example(`eik alias lodash 4.17.19 4`);
|
|
72
|
+
yargs.example(
|
|
73
|
+
`eik alias my-map 6.3.1 6 --server https://assets.myeikserver.com`,
|
|
74
|
+
);
|
|
75
|
+
yargs.example(`eik alias my-map 4.2.2 4 --debug`);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.handler = async (argv) => {
|
|
79
|
+
const spinner = ora({ stream: process.stdout }).start('working...');
|
|
80
|
+
let success = false;
|
|
81
|
+
const { cwd, type: typeFromArgs, debug } = argv;
|
|
82
|
+
const config = configStore.findInDirectory(cwd);
|
|
83
|
+
const { server, type } = config;
|
|
84
|
+
|
|
85
|
+
const typeOverride = typeFromArgs || type;
|
|
86
|
+
const log = logger(spinner, debug);
|
|
87
|
+
|
|
88
|
+
const isPackage = ['package', 'npm'].includes(typeOverride);
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const data = await new Alias({
|
|
92
|
+
type:
|
|
93
|
+
typeOverride === 'package'
|
|
94
|
+
? 'pkg'
|
|
95
|
+
: typeOverride === 'npm'
|
|
96
|
+
? 'npm'
|
|
97
|
+
: typeOverride === 'map'
|
|
98
|
+
? 'map'
|
|
99
|
+
: 'pkg',
|
|
100
|
+
logger: log,
|
|
101
|
+
...argv,
|
|
102
|
+
}).run();
|
|
103
|
+
|
|
104
|
+
const createdOrUpdated = data.update ? 'Updated' : 'Created';
|
|
105
|
+
log.info(
|
|
106
|
+
`${createdOrUpdated} alias for ${isPackage ? 'package' : 'map'} "${
|
|
107
|
+
data.name
|
|
108
|
+
}". ("${data.version}" => "v${data.alias}")`,
|
|
109
|
+
);
|
|
110
|
+
success = true;
|
|
111
|
+
|
|
112
|
+
spinner.text = '';
|
|
113
|
+
spinner.stopAndPersist();
|
|
114
|
+
if (success) {
|
|
115
|
+
new AliasFormatter(data).format(server);
|
|
116
|
+
} else {
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
} catch (err) {
|
|
120
|
+
spinner.warn(err.message);
|
|
121
|
+
spinner.text = '';
|
|
122
|
+
spinner.stopAndPersist();
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
};
|
package/commands/integrity.js
CHANGED
|
@@ -6,11 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
const { join } = require('path');
|
|
8
8
|
const ora = require('ora');
|
|
9
|
-
const {
|
|
10
|
-
helpers: { configStore },
|
|
11
|
-
} = require('@eik/common');
|
|
9
|
+
const { configStore, getDefaults } = require('@eik/common-config-loader');
|
|
12
10
|
const Integrity = require('../classes/integrity');
|
|
13
|
-
const { logger,
|
|
11
|
+
const { logger, getCWD } = require('../utils');
|
|
14
12
|
const json = require('../utils/json');
|
|
15
13
|
|
|
16
14
|
exports.command = 'integrity [name] [version]';
|
package/commands/login.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const homedir = require('os').homedir();
|
|
4
|
+
const { getDefaults } = require('@eik/common-config-loader');
|
|
4
5
|
const readline = require('readline');
|
|
5
6
|
const ora = require('ora');
|
|
6
7
|
const Login = require('../classes/login');
|
|
7
|
-
const { logger,
|
|
8
|
+
const { logger, getCWD } = require('../utils');
|
|
8
9
|
const json = require('../utils/json');
|
|
9
10
|
|
|
10
11
|
exports.command = 'login';
|
package/commands/meta.js
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
const ora = require('ora');
|
|
8
|
+
const { getDefaults } = require('@eik/common-config-loader');
|
|
8
9
|
const Meta = require('../classes/meta');
|
|
9
10
|
const { Artifact } = require('../formatters');
|
|
10
|
-
const { logger,
|
|
11
|
+
const { logger, getCWD } = require('../utils');
|
|
11
12
|
|
|
12
13
|
exports.command = 'meta <name>';
|
|
13
14
|
|
package/commands/ping.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const ora = require('ora');
|
|
4
|
+
const { getDefaults } = require('@eik/common-config-loader');
|
|
4
5
|
const Ping = require('../classes/ping');
|
|
5
|
-
const { logger,
|
|
6
|
+
const { logger, getCWD } = require('../utils');
|
|
6
7
|
|
|
7
8
|
exports.command = 'ping [server]';
|
|
8
9
|
|
package/commands/publish.js
CHANGED
|
@@ -4,24 +4,20 @@ const { join } = require('path');
|
|
|
4
4
|
const fetch = require('node-fetch');
|
|
5
5
|
const ora = require('ora');
|
|
6
6
|
const chalk = require('chalk');
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const { configStore, getDefaults } = require('@eik/common-config-loader');
|
|
8
|
+
const { typeSlug, typeTitle } = require('@eik/common-utils');
|
|
9
|
+
|
|
10
10
|
const PublishPackage = require('../classes/publish/package/index');
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
getDefaults,
|
|
14
|
-
getCWD,
|
|
15
|
-
typeSlug,
|
|
16
|
-
typeTitle,
|
|
17
|
-
} = require('../utils');
|
|
11
|
+
const { logger, getCWD } = require('../utils');
|
|
12
|
+
|
|
18
13
|
const { Artifact } = require('../formatters');
|
|
14
|
+
const PublishMap = require('../classes/publish/map');
|
|
19
15
|
|
|
20
16
|
exports.command = 'publish';
|
|
21
17
|
|
|
22
18
|
exports.aliases = ['pkg', 'package', 'pub'];
|
|
23
19
|
|
|
24
|
-
exports.describe = `Publish
|
|
20
|
+
exports.describe = `Publish files to an Eik server. Reads configuration from eik.json or package.json files. See https://eik.dev for more details.`;
|
|
25
21
|
|
|
26
22
|
exports.builder = (yargs) => {
|
|
27
23
|
const cwd = getCWD();
|
|
@@ -52,6 +48,18 @@ exports.builder = (yargs) => {
|
|
|
52
48
|
type: 'string',
|
|
53
49
|
alias: 't',
|
|
54
50
|
},
|
|
51
|
+
type: {
|
|
52
|
+
describe:
|
|
53
|
+
'Optional flag to define the type of asset you wish to publish. This can be "package", "map" or "npm". Default reads from eik configuration "type" field.',
|
|
54
|
+
default: '',
|
|
55
|
+
type: 'string',
|
|
56
|
+
},
|
|
57
|
+
file: {
|
|
58
|
+
describe:
|
|
59
|
+
'Path to import map file on local disk relative to the current working directory. Default reads the "files" in the eik config.',
|
|
60
|
+
type: 'string',
|
|
61
|
+
normalize: true,
|
|
62
|
+
},
|
|
55
63
|
});
|
|
56
64
|
|
|
57
65
|
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
|
@@ -65,87 +73,113 @@ exports.builder = (yargs) => {
|
|
|
65
73
|
|
|
66
74
|
exports.handler = async (argv) => {
|
|
67
75
|
const spinner = ora({ stream: process.stdout }).start('working...');
|
|
68
|
-
const { debug, dryRun, cwd, token } = argv;
|
|
76
|
+
const { debug, dryRun, cwd, token, type: typeFromArgs } = argv;
|
|
69
77
|
const config = configStore.findInDirectory(cwd);
|
|
70
78
|
const { name, server, version, type, map, out, files } = config;
|
|
71
79
|
|
|
72
|
-
|
|
73
|
-
spinner.warn(
|
|
74
|
-
'"type" is set to "map", which is not supported by the publish command. Please use the "eik map" command instead',
|
|
75
|
-
);
|
|
76
|
-
process.stdout.write('\n');
|
|
77
|
-
process.exit(0);
|
|
78
|
-
}
|
|
80
|
+
const typeOverride = typeFromArgs || type;
|
|
79
81
|
|
|
80
82
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
83
|
+
if (['package', 'npm'].includes(typeOverride)) {
|
|
84
|
+
const options = {
|
|
85
|
+
logger: logger(spinner, debug),
|
|
86
|
+
cwd,
|
|
87
|
+
token,
|
|
88
|
+
dryRun,
|
|
89
|
+
debug,
|
|
90
|
+
name,
|
|
91
|
+
server,
|
|
92
|
+
version,
|
|
93
|
+
type,
|
|
94
|
+
map,
|
|
95
|
+
out,
|
|
96
|
+
files,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const publish = await new PublishPackage(options).run();
|
|
100
|
+
|
|
101
|
+
if (!publish) {
|
|
102
|
+
spinner.warn(
|
|
103
|
+
'Version in eik.json has not changed since last publish, publishing is not necessary',
|
|
104
|
+
);
|
|
105
|
+
process.stdout.write('\n');
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const { files: fls } = publish;
|
|
110
|
+
|
|
111
|
+
if (!dryRun) {
|
|
112
|
+
let url = new URL(join(typeSlug(type), name), server);
|
|
113
|
+
let res = await fetch(url);
|
|
114
|
+
const pkgMeta = await res.json();
|
|
115
|
+
|
|
116
|
+
url = new URL(join(typeSlug(type), name, version), server);
|
|
117
|
+
res = await fetch(url);
|
|
118
|
+
const pkgVersionMeta = await res.json();
|
|
119
|
+
|
|
120
|
+
const artifact = new Artifact(pkgMeta);
|
|
121
|
+
artifact.versions = [pkgVersionMeta];
|
|
105
122
|
|
|
106
|
-
|
|
123
|
+
spinner.text = '';
|
|
124
|
+
spinner.stopAndPersist();
|
|
107
125
|
|
|
108
|
-
|
|
109
|
-
|
|
126
|
+
artifact.format(server);
|
|
127
|
+
process.stdout.write('\n');
|
|
128
|
+
} else {
|
|
129
|
+
spinner.text = '';
|
|
130
|
+
spinner.stopAndPersist();
|
|
131
|
+
|
|
132
|
+
process.stdout.write(
|
|
133
|
+
`:: ${chalk.bgYellow.white.bold(
|
|
134
|
+
typeTitle(type),
|
|
135
|
+
)} > ${chalk.green(name)} | ${chalk.bold('dry run')}`,
|
|
136
|
+
);
|
|
137
|
+
process.stdout.write('\n\n');
|
|
138
|
+
process.stdout.write(' files (local temporary):\n');
|
|
139
|
+
for (const file of fls) {
|
|
140
|
+
process.stdout.write(
|
|
141
|
+
` - ${chalk.bold('type')}: ${file.type}\n`,
|
|
142
|
+
);
|
|
143
|
+
process.stdout.write(
|
|
144
|
+
` ${chalk.bold('path')}: ${file.pathname}\n\n`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
process.stdout.write(
|
|
148
|
+
` ${chalk.bold(
|
|
149
|
+
'No files were published to remote server',
|
|
150
|
+
)}\n\n`,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
} else if (typeOverride === 'map') {
|
|
154
|
+
const log = logger(spinner, debug);
|
|
155
|
+
|
|
156
|
+
await new PublishMap({
|
|
157
|
+
logger: log,
|
|
158
|
+
name,
|
|
159
|
+
version,
|
|
160
|
+
server,
|
|
161
|
+
file: files,
|
|
162
|
+
...argv,
|
|
163
|
+
}).run();
|
|
164
|
+
|
|
165
|
+
let url = new URL(join('map', name), server);
|
|
110
166
|
let res = await fetch(url);
|
|
111
167
|
const pkgMeta = await res.json();
|
|
112
168
|
|
|
113
|
-
url = new URL(join(
|
|
169
|
+
url = new URL(join('map', name, version), server);
|
|
114
170
|
res = await fetch(url);
|
|
115
|
-
const pkgVersionMeta = await res.json();
|
|
116
171
|
|
|
117
|
-
|
|
118
|
-
artifact.versions = [pkgVersionMeta];
|
|
172
|
+
log.info(`Published import map "${name}" at version "${version}"`);
|
|
119
173
|
|
|
120
174
|
spinner.text = '';
|
|
121
175
|
spinner.stopAndPersist();
|
|
122
176
|
|
|
177
|
+
const artifact = new Artifact(pkgMeta);
|
|
178
|
+
const versions = new Map(pkgMeta.versions);
|
|
179
|
+
artifact.versions = Array.from(versions.values());
|
|
123
180
|
artifact.format(server);
|
|
124
|
-
process.stdout.write('\n');
|
|
125
|
-
} else {
|
|
126
|
-
spinner.text = '';
|
|
127
|
-
spinner.stopAndPersist();
|
|
128
181
|
|
|
129
|
-
process.stdout.write(
|
|
130
|
-
`:: ${chalk.bgYellow.white.bold(
|
|
131
|
-
typeTitle(type),
|
|
132
|
-
)} > ${chalk.green(name)} | ${chalk.bold('dry run')}`,
|
|
133
|
-
);
|
|
134
|
-
process.stdout.write('\n\n');
|
|
135
|
-
process.stdout.write(' files (local temporary):\n');
|
|
136
|
-
for (const file of fls) {
|
|
137
|
-
process.stdout.write(
|
|
138
|
-
` - ${chalk.bold('type')}: ${file.type}\n`,
|
|
139
|
-
);
|
|
140
|
-
process.stdout.write(
|
|
141
|
-
` ${chalk.bold('path')}: ${file.pathname}\n\n`,
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
process.stdout.write(
|
|
145
|
-
` ${chalk.bold(
|
|
146
|
-
'No files were published to remote server',
|
|
147
|
-
)}\n\n`,
|
|
148
|
-
);
|
|
182
|
+
process.stdout.write('\n');
|
|
149
183
|
}
|
|
150
184
|
} catch (err) {
|
|
151
185
|
spinner.warn(err.message);
|
package/commands/version.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
const { execSync } = require('child_process');
|
|
4
4
|
const { join } = require('path');
|
|
5
5
|
const ora = require('ora');
|
|
6
|
-
const {
|
|
7
|
-
helpers: { configStore },
|
|
8
|
-
} = require('@eik/common');
|
|
6
|
+
const { configStore, getDefaults } = require('@eik/common-config-loader');
|
|
9
7
|
const VersionPackage = require('../classes/version');
|
|
10
|
-
const { logger,
|
|
8
|
+
const { logger, getCWD } = require('../utils');
|
|
11
9
|
const json = require('../utils/json');
|
|
12
10
|
|
|
13
11
|
exports.command = 'version [level]';
|
package/formatters/alias.js
CHANGED
|
@@ -55,6 +55,12 @@ class Alias {
|
|
|
55
55
|
|
|
56
56
|
if (this.update) {
|
|
57
57
|
write(`${chalk.bgMagenta.white(' UPDATED \n\n')}`);
|
|
58
|
+
|
|
59
|
+
write(
|
|
60
|
+
`${chalk.yellow.bold(
|
|
61
|
+
'! It may take up to 40 minutes before this alias updates due to caching.',
|
|
62
|
+
)}\n\n`,
|
|
63
|
+
);
|
|
58
64
|
} else {
|
|
59
65
|
write(`${chalk.bgGreen.white(' NEW ')}\n\n`);
|
|
60
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eik/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.2",
|
|
4
4
|
"description": "Cli tool for publishing assets",
|
|
5
5
|
"main": "./classes/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,10 +32,13 @@
|
|
|
32
32
|
"author": "",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@eik/common": "^
|
|
35
|
+
"@eik/common-config-loader": "^4.0.0-next.8",
|
|
36
|
+
"@eik/common-schemas": "^4.0.0-next.8",
|
|
37
|
+
"@eik/common-utils": "^4.0.0-next.8",
|
|
38
|
+
"@eik/common-validators": "^4.0.0-next.8",
|
|
36
39
|
"abslog": "2.4.0",
|
|
37
40
|
"boxen": "5.1.2",
|
|
38
|
-
"bytes": "3.1.
|
|
41
|
+
"bytes": "3.1.2",
|
|
39
42
|
"chalk": "4.1.2",
|
|
40
43
|
"copy": "0.3.2",
|
|
41
44
|
"date-fns": "2.28.0",
|
|
@@ -60,20 +63,20 @@
|
|
|
60
63
|
"@eik/service": "1.2.98",
|
|
61
64
|
"@semantic-release/changelog": "6.0.1",
|
|
62
65
|
"@semantic-release/git": "10.0.1",
|
|
63
|
-
"eslint": "8.
|
|
66
|
+
"eslint": "8.8.0",
|
|
64
67
|
"eslint-config-airbnb-base": "15.0.0",
|
|
65
68
|
"eslint-config-prettier": "8.3.0",
|
|
66
69
|
"eslint-plugin-import": "2.25.4",
|
|
67
70
|
"eslint-plugin-prettier": "4.0.0",
|
|
68
|
-
"fastify": "3.
|
|
71
|
+
"fastify": "3.27.0",
|
|
69
72
|
"fastify-cors": "6.0.2",
|
|
70
73
|
"fs-extra": "10.0.0",
|
|
71
74
|
"prettier": "2.5.1",
|
|
72
|
-
"puppeteer": "13.
|
|
75
|
+
"puppeteer": "13.1.2",
|
|
73
76
|
"react": "17.0.2",
|
|
74
77
|
"react-dom": "17.0.2",
|
|
75
|
-
"semantic-release": "
|
|
76
|
-
"semantic-release-slack-bot": "3.
|
|
78
|
+
"semantic-release": "19.0.2",
|
|
79
|
+
"semantic-release-slack-bot": "3.5.2",
|
|
77
80
|
"tap": "15.1.6"
|
|
78
81
|
}
|
|
79
82
|
}
|
package/utils/index.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
helpers: { getDefaults, files },
|
|
5
|
-
} = require('@eik/common');
|
|
6
3
|
const logger = require('./logger');
|
|
7
4
|
const getCWD = require('./get-cwd');
|
|
8
|
-
const typeSlug = require('./type-slug');
|
|
9
|
-
const typeTitle = require('./type-title');
|
|
10
5
|
|
|
11
|
-
module.exports = { logger,
|
|
6
|
+
module.exports = { logger, getCWD };
|
package/commands/map-alias.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ora = require('ora');
|
|
4
|
-
const Alias = require('../classes/alias');
|
|
5
|
-
const { logger, getDefaults, getCWD } = require('../utils');
|
|
6
|
-
const { Alias: AliasFormatter } = require('../formatters');
|
|
7
|
-
|
|
8
|
-
exports.command = 'map-alias <name> <version> <alias>';
|
|
9
|
-
|
|
10
|
-
exports.aliases = ['ma'];
|
|
11
|
-
|
|
12
|
-
exports.describe = `Create a semver major alias for an import map as identified by its name and version.
|
|
13
|
-
An import map with the given name and version must already exist on asset server
|
|
14
|
-
Alias should be the semver major part of the import map version.
|
|
15
|
-
Eg. For an import map of version 5.4.3, you should use 5 as the alias`;
|
|
16
|
-
|
|
17
|
-
exports.builder = (yargs) => {
|
|
18
|
-
const cwd = getCWD();
|
|
19
|
-
const defaults = getDefaults(cwd);
|
|
20
|
-
|
|
21
|
-
yargs
|
|
22
|
-
.positional('name', {
|
|
23
|
-
describe: `Import map name for import map that is to be aliased`,
|
|
24
|
-
type: 'string',
|
|
25
|
-
})
|
|
26
|
-
.positional('version', {
|
|
27
|
-
describe: `Import map version for import map that is to be aliased`,
|
|
28
|
-
type: 'string',
|
|
29
|
-
})
|
|
30
|
-
.positional('alias', {
|
|
31
|
-
describe: `Alias for a semver version. Should be the semver major component of version.`,
|
|
32
|
-
type: 'string',
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
yargs.options({
|
|
36
|
-
server: {
|
|
37
|
-
alias: 's',
|
|
38
|
-
describe: 'Specify location of asset server.',
|
|
39
|
-
default: defaults.server,
|
|
40
|
-
},
|
|
41
|
-
cwd: {
|
|
42
|
-
alias: 'c',
|
|
43
|
-
describe: 'Alter current working directory.',
|
|
44
|
-
default: defaults.cwd,
|
|
45
|
-
},
|
|
46
|
-
debug: {
|
|
47
|
-
describe: 'Logs additional messages',
|
|
48
|
-
default: false,
|
|
49
|
-
type: 'boolean',
|
|
50
|
-
},
|
|
51
|
-
token: {
|
|
52
|
-
describe:
|
|
53
|
-
'Provide a jwt token to be used to authenticate with the Eik server.',
|
|
54
|
-
default: '',
|
|
55
|
-
alias: 't',
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
|
60
|
-
|
|
61
|
-
yargs.example(`eik map-alias my-map 1.0.0 1`);
|
|
62
|
-
yargs.example(`eik map-alias my-map 1.7.3 1`);
|
|
63
|
-
yargs.example(`eik map-alias my-map 6.3.1 6`);
|
|
64
|
-
yargs.example(
|
|
65
|
-
`eik map-alias my-map 6.3.1 6 --server https://assets.myeikserver.com`,
|
|
66
|
-
);
|
|
67
|
-
yargs.example(`eik map-alias my-map 4.2.2 4 --debug`);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
exports.handler = async (argv) => {
|
|
71
|
-
const spinner = ora({ stream: process.stdout }).start('working...');
|
|
72
|
-
let success = false;
|
|
73
|
-
const { debug, name, version, server } = argv;
|
|
74
|
-
const log = logger(spinner, debug);
|
|
75
|
-
let data = {};
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
data = await new Alias({
|
|
79
|
-
type: 'map',
|
|
80
|
-
logger: log,
|
|
81
|
-
...argv,
|
|
82
|
-
}).run();
|
|
83
|
-
|
|
84
|
-
data.name = name;
|
|
85
|
-
data.version = version;
|
|
86
|
-
data.files = [];
|
|
87
|
-
|
|
88
|
-
const createdOrUpdated = data.update ? 'Updated' : 'Created';
|
|
89
|
-
log.info(
|
|
90
|
-
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
|
91
|
-
);
|
|
92
|
-
success = true;
|
|
93
|
-
} catch (err) {
|
|
94
|
-
log.warn(err.message);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
spinner.text = '';
|
|
98
|
-
spinner.stopAndPersist();
|
|
99
|
-
if (success) {
|
|
100
|
-
new AliasFormatter(data).format(server);
|
|
101
|
-
} else {
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
};
|
package/commands/map.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
const fetch = require('node-fetch');
|
|
5
|
-
const ora = require('ora');
|
|
6
|
-
const PublishMap = require('../classes/publish/map');
|
|
7
|
-
const { logger, getDefaults, getCWD } = require('../utils');
|
|
8
|
-
const { Artifact } = require('../formatters');
|
|
9
|
-
|
|
10
|
-
exports.command = 'map <name> <version> <file>';
|
|
11
|
-
|
|
12
|
-
exports.aliases = ['m'];
|
|
13
|
-
|
|
14
|
-
exports.describe = `Upload an import map file to the server under a given name and version.
|
|
15
|
-
A name/version combination must be unique and a version must be semver compliant.
|
|
16
|
-
Subsquent published versions must increase. Eg. 1.0.0 1.0.1, 1.1.0, 2.0.0 etc.`;
|
|
17
|
-
|
|
18
|
-
exports.builder = (yargs) => {
|
|
19
|
-
const cwd = getCWD();
|
|
20
|
-
const defaults = getDefaults(cwd);
|
|
21
|
-
|
|
22
|
-
yargs
|
|
23
|
-
.positional('name', {
|
|
24
|
-
describe: 'Import map name.',
|
|
25
|
-
type: 'string',
|
|
26
|
-
})
|
|
27
|
-
.positional('version', {
|
|
28
|
-
describe: 'Import map version.',
|
|
29
|
-
type: 'string',
|
|
30
|
-
})
|
|
31
|
-
.positional('file', {
|
|
32
|
-
describe:
|
|
33
|
-
'Path to import map file on local disk relative to the current working directory.',
|
|
34
|
-
type: 'string',
|
|
35
|
-
normalize: true,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
yargs.options({
|
|
39
|
-
server: {
|
|
40
|
-
alias: 's',
|
|
41
|
-
describe: 'Specify location of asset server.',
|
|
42
|
-
default: defaults.server,
|
|
43
|
-
},
|
|
44
|
-
cwd: {
|
|
45
|
-
alias: 'c',
|
|
46
|
-
describe: 'Alter current working directory.',
|
|
47
|
-
default: defaults.cwd,
|
|
48
|
-
},
|
|
49
|
-
debug: {
|
|
50
|
-
describe: 'Logs additional messages',
|
|
51
|
-
default: false,
|
|
52
|
-
type: 'boolean',
|
|
53
|
-
},
|
|
54
|
-
token: {
|
|
55
|
-
describe:
|
|
56
|
-
'Provide a jwt token to be used to authenticate with the Eik server.',
|
|
57
|
-
default: '',
|
|
58
|
-
alias: 't',
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
|
63
|
-
|
|
64
|
-
yargs.example(`eik map my-map 1.0.0 ./import-map.json`);
|
|
65
|
-
yargs.example(`eik map my-map 2.1.0 ./import-map.json --debug`);
|
|
66
|
-
yargs.example(
|
|
67
|
-
`eik map my-map 2.1.1 ./import-map.json --server https://assets.myeikserver.com`,
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
exports.handler = async (argv) => {
|
|
72
|
-
const spinner = ora({ stream: process.stdout }).start('working...');
|
|
73
|
-
const { debug, server, name, version } = argv;
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const log = logger(spinner, debug);
|
|
77
|
-
|
|
78
|
-
await new PublishMap({ logger: log, ...argv }).run();
|
|
79
|
-
|
|
80
|
-
let url = new URL(join('map', name), server);
|
|
81
|
-
let res = await fetch(url);
|
|
82
|
-
const pkgMeta = await res.json();
|
|
83
|
-
|
|
84
|
-
url = new URL(join('map', name, version), server);
|
|
85
|
-
res = await fetch(url);
|
|
86
|
-
|
|
87
|
-
log.info(`Published import map "${name}" at version "${version}"`);
|
|
88
|
-
|
|
89
|
-
spinner.text = '';
|
|
90
|
-
spinner.stopAndPersist();
|
|
91
|
-
|
|
92
|
-
const artifact = new Artifact(pkgMeta);
|
|
93
|
-
const versions = new Map(pkgMeta.versions);
|
|
94
|
-
artifact.versions = Array.from(versions.values());
|
|
95
|
-
artifact.format(server);
|
|
96
|
-
|
|
97
|
-
process.stdout.write('\n');
|
|
98
|
-
} catch (err) {
|
|
99
|
-
spinner.warn(err.message);
|
|
100
|
-
spinner.text = '';
|
|
101
|
-
spinner.stopAndPersist();
|
|
102
|
-
process.exit(1);
|
|
103
|
-
}
|
|
104
|
-
};
|
package/commands/npm-alias.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ora = require('ora');
|
|
4
|
-
const Alias = require('../classes/alias');
|
|
5
|
-
const { logger, getDefaults, getCWD } = require('../utils');
|
|
6
|
-
const { Alias: AliasFormatter } = require('../formatters');
|
|
7
|
-
|
|
8
|
-
exports.command = 'npm-alias <name> <version> <alias>';
|
|
9
|
-
|
|
10
|
-
exports.aliases = ['na', 'dep-alias', 'dependency-alias'];
|
|
11
|
-
|
|
12
|
-
exports.describe = `Create a semver major alias for an NPM package as identified by its name and version.
|
|
13
|
-
An NPM package with the given name and version must already exist on the asset server
|
|
14
|
-
Alias should be the semver major part of the NPM package version.
|
|
15
|
-
Eg. For an NPM package of version 5.4.3, you should use 5 as the alias`;
|
|
16
|
-
|
|
17
|
-
exports.builder = (yargs) => {
|
|
18
|
-
const cwd = getCWD();
|
|
19
|
-
const defaults = getDefaults(cwd);
|
|
20
|
-
|
|
21
|
-
yargs
|
|
22
|
-
.positional('name', {
|
|
23
|
-
describe: 'Name matching NPM package name.',
|
|
24
|
-
type: 'string',
|
|
25
|
-
})
|
|
26
|
-
.positional('version', {
|
|
27
|
-
describe: 'Version matching NPM package version.',
|
|
28
|
-
type: 'string',
|
|
29
|
-
})
|
|
30
|
-
.positional('alias', {
|
|
31
|
-
describe:
|
|
32
|
-
'Alias for a semver version. Must be the semver major component of version.',
|
|
33
|
-
type: 'string',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
yargs.options({
|
|
37
|
-
server: {
|
|
38
|
-
alias: 's',
|
|
39
|
-
describe: 'Specify location of asset server.',
|
|
40
|
-
default: defaults.server,
|
|
41
|
-
},
|
|
42
|
-
cwd: {
|
|
43
|
-
alias: 'c',
|
|
44
|
-
describe: 'Alter current working directory.',
|
|
45
|
-
default: defaults.cwd,
|
|
46
|
-
},
|
|
47
|
-
debug: {
|
|
48
|
-
describe: 'Logs additional messages',
|
|
49
|
-
default: false,
|
|
50
|
-
type: 'boolean',
|
|
51
|
-
},
|
|
52
|
-
token: {
|
|
53
|
-
describe:
|
|
54
|
-
'Provide a jwt token to be used to authenticate with the Eik server.',
|
|
55
|
-
default: '',
|
|
56
|
-
alias: 't',
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
|
61
|
-
|
|
62
|
-
yargs.example(`eik npm lit-html 1.0.0 1`);
|
|
63
|
-
yargs.example(`eik npm lit-html 1.3.5 1 --debug`);
|
|
64
|
-
yargs.example(
|
|
65
|
-
`eik npm lit-html 5.3.2 5 --server https://assets.myeikserver.com`,
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.handler = async (argv) => {
|
|
70
|
-
const spinner = ora({ stream: process.stdout }).start('working...');
|
|
71
|
-
let success = false;
|
|
72
|
-
const { debug, server } = argv;
|
|
73
|
-
const log = logger(spinner, debug);
|
|
74
|
-
let data = {};
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
data = await new Alias({
|
|
78
|
-
type: 'npm',
|
|
79
|
-
logger: log,
|
|
80
|
-
...argv,
|
|
81
|
-
}).run();
|
|
82
|
-
|
|
83
|
-
const createdOrUpdated = data.update ? 'Updated' : 'Created';
|
|
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
|
-
}
|
|
91
|
-
|
|
92
|
-
spinner.text = '';
|
|
93
|
-
spinner.stopAndPersist();
|
|
94
|
-
if (success) {
|
|
95
|
-
new AliasFormatter(data).format(server);
|
|
96
|
-
} else {
|
|
97
|
-
process.exit(1);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ora = require('ora');
|
|
4
|
-
const semver = require('semver');
|
|
5
|
-
const Alias = require('../classes/alias');
|
|
6
|
-
const { logger, getDefaults, getCWD } = require('../utils');
|
|
7
|
-
const { Alias: AliasFormatter } = require('../formatters');
|
|
8
|
-
|
|
9
|
-
exports.command = 'package-alias [name] [version] [alias]';
|
|
10
|
-
|
|
11
|
-
exports.aliases = ['pkg-alias', 'pa'];
|
|
12
|
-
|
|
13
|
-
exports.describe = `Create a semver major alias for a package as identified by its name and version.
|
|
14
|
-
A package with the given name and version must already exist on asset server
|
|
15
|
-
Alias should be the semver major part of the package version.
|
|
16
|
-
Eg. For a package of version 5.4.3, you should use 5 as the alias`;
|
|
17
|
-
|
|
18
|
-
exports.builder = (yargs) => {
|
|
19
|
-
const cwd = getCWD();
|
|
20
|
-
const defaults = getDefaults(cwd);
|
|
21
|
-
|
|
22
|
-
yargs
|
|
23
|
-
.positional('name', {
|
|
24
|
-
describe: 'Name matching existing name for a package on Eik server',
|
|
25
|
-
type: 'string',
|
|
26
|
-
default: defaults.name,
|
|
27
|
-
})
|
|
28
|
-
.positional('version', {
|
|
29
|
-
describe:
|
|
30
|
-
'Version matching existing version for a package on Eik server',
|
|
31
|
-
type: 'string',
|
|
32
|
-
default: defaults.version,
|
|
33
|
-
})
|
|
34
|
-
.positional('alias', {
|
|
35
|
-
describe:
|
|
36
|
-
'Alias for a semver version. Must be the semver major component of version. Eg. 1.0.0 should be given as 1',
|
|
37
|
-
type: 'string',
|
|
38
|
-
default: defaults.version ? semver.major(defaults.version) : null,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
yargs.options({
|
|
42
|
-
server: {
|
|
43
|
-
alias: 's',
|
|
44
|
-
describe: 'Specify location of Eik asset server.',
|
|
45
|
-
default: defaults.server,
|
|
46
|
-
},
|
|
47
|
-
cwd: {
|
|
48
|
-
alias: 'c',
|
|
49
|
-
describe: 'Alter the current working directory.',
|
|
50
|
-
default: defaults.cwd,
|
|
51
|
-
},
|
|
52
|
-
debug: {
|
|
53
|
-
describe: 'Logs additional messages',
|
|
54
|
-
default: false,
|
|
55
|
-
type: 'boolean',
|
|
56
|
-
},
|
|
57
|
-
token: {
|
|
58
|
-
describe:
|
|
59
|
-
'Provide a jwt token to be used to authenticate with the Eik server.',
|
|
60
|
-
default: '',
|
|
61
|
-
alias: 't',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
yargs.default('token', defaults.token, defaults.token ? '######' : '');
|
|
66
|
-
|
|
67
|
-
yargs.example(`eik package-alias my-app 1.0.0 1`);
|
|
68
|
-
yargs.example(`eik package-alias my-app 1.7.3 1`);
|
|
69
|
-
yargs.example(`eik package-alias my-app 6.3.1 6`);
|
|
70
|
-
yargs.example(
|
|
71
|
-
`eik package-alias my-app 6.3.1 6 --server https://assets.myeikserver.com`,
|
|
72
|
-
);
|
|
73
|
-
yargs.example(`eik package-alias my-app 4.2.2 4 --debug`);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.handler = async (argv) => {
|
|
77
|
-
const spinner = ora({ stream: process.stdout }).start('working...');
|
|
78
|
-
let success = false;
|
|
79
|
-
const { debug, server } = argv;
|
|
80
|
-
const log = logger(spinner, debug);
|
|
81
|
-
let af;
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const data = await new Alias({
|
|
85
|
-
type: 'pkg',
|
|
86
|
-
logger: log,
|
|
87
|
-
...argv,
|
|
88
|
-
}).run();
|
|
89
|
-
|
|
90
|
-
af = new AliasFormatter(data);
|
|
91
|
-
|
|
92
|
-
const createdOrUpdated = data.update ? 'Updated' : 'Created';
|
|
93
|
-
log.info(
|
|
94
|
-
`${createdOrUpdated} alias for package "${data.name}". ("${data.version}" => "v${data.alias}")`,
|
|
95
|
-
);
|
|
96
|
-
success = true;
|
|
97
|
-
} catch (err) {
|
|
98
|
-
log.warn(err.message);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
spinner.text = '';
|
|
102
|
-
spinner.stopAndPersist();
|
|
103
|
-
if (success) {
|
|
104
|
-
af.format(server);
|
|
105
|
-
} else {
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
};
|