@todesktop/cli 1.5.1 → 1.6.1
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/dist/cli.js +4430 -0
- package/dist/cli.js.map +7 -0
- package/package.json +41 -41
- package/build/boot.js +0 -126
- package/build/cli.js +0 -11
- package/build/cli.js.bak +0 -11
- package/build/commands/build.js +0 -124
- package/build/commands/build.js.map +0 -1
- package/build/commands/builds.js +0 -116
- package/build/commands/builds.js.map +0 -1
- package/build/commands/logout.js +0 -60
- package/build/commands/logout.js.map +0 -1
- package/build/commands/release.js +0 -94
- package/build/commands/release.js.map +0 -1
- package/build/commands/whoami.js +0 -60
- package/build/commands/whoami.js.map +0 -1
- package/build/commands.json +0 -152
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"name": "@todesktop/cli",
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.6.1",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"author": "Dave Jeffery <dave@todesktop.com> (http://www.todesktop.com/)",
|
|
10
10
|
"homepage": "https://todesktop.com/cli",
|
|
@@ -12,46 +12,45 @@
|
|
|
12
12
|
"email": "dave@todesktop.com"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
|
-
"todesktop": "./
|
|
15
|
+
"todesktop": "./dist/cli.js"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=12"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"dev": "cp-cli dev.env .env &&
|
|
22
|
-
"dev:prod": "cp-cli prod.env .env &&
|
|
23
|
-
"build": "
|
|
24
|
-
"build:dev": "
|
|
25
|
-
"lint": "
|
|
26
|
-
"lint
|
|
21
|
+
"dev": "cp-cli dev.env .env && npm run build:dev && npm link",
|
|
22
|
+
"dev:prod": "cp-cli prod.env .env && npm run build && npm link",
|
|
23
|
+
"build": "esbuild src/index.ts --packages=external --bundle --sourcemap --platform=node --outfile=dist/cli.js && cp-cli prod.env .env",
|
|
24
|
+
"build:dev": "esbuild src/index.ts --packages=external --bundle --sourcemap --platform=node --outfile=dist/cli.js && cp-cli prod.env .env",
|
|
25
|
+
"lint": "npm run lint:types && npm run lint:styles",
|
|
26
|
+
"lint:styles": "eslint src test .eslintrc.js",
|
|
27
|
+
"lint:types": "tsc",
|
|
28
|
+
"lint--fix": "eslint src test --fix",
|
|
27
29
|
"release": "npm run build && npx np --tag=latest",
|
|
28
30
|
"release-beta": "npm run build && npx np --any-branch --no-tests --tag=beta",
|
|
29
|
-
"test": "
|
|
31
|
+
"test": "ava",
|
|
30
32
|
"test--watch": "npm test -- --watch"
|
|
31
33
|
},
|
|
32
34
|
"files": [
|
|
33
|
-
"
|
|
35
|
+
"dist",
|
|
34
36
|
"docs",
|
|
35
37
|
".env",
|
|
36
38
|
"LICENSE",
|
|
37
39
|
"README.md"
|
|
38
40
|
],
|
|
39
41
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.18.9",
|
|
41
42
|
"@sentry/node": "^5.27.2",
|
|
42
|
-
"ajv": "^
|
|
43
|
+
"ajv": "^8.11.2",
|
|
44
|
+
"ajv-formats": "^2.1.1",
|
|
43
45
|
"analytics-node": "^4.0.1",
|
|
44
46
|
"archiver": "^5.2.0",
|
|
45
47
|
"axios": "^0.21.1",
|
|
46
48
|
"better-ajv-errors": "^1.2.0",
|
|
47
|
-
"blacklist": "^1.1.4",
|
|
48
49
|
"bunyan": "^1.8.14",
|
|
49
|
-
"camelcase-keys": "^5.2.0",
|
|
50
50
|
"chalk": "^4.1.0",
|
|
51
|
-
"
|
|
51
|
+
"commander": "^9.4.1",
|
|
52
52
|
"conf": "^7.1.2",
|
|
53
53
|
"date-fns": "^2.28.0",
|
|
54
|
-
"decamelize": "^1.2.0",
|
|
55
54
|
"del": "^6.0.0",
|
|
56
55
|
"dotenv": "^8.2.0",
|
|
57
56
|
"du": "^1.0.0",
|
|
@@ -78,57 +77,58 @@
|
|
|
78
77
|
"react": "^17.0.2",
|
|
79
78
|
"react-final-form": "^6.5.1",
|
|
80
79
|
"semver": "^7.3.2",
|
|
80
|
+
"source-map-support": "^0.5.21",
|
|
81
81
|
"stream-to-array": "^2.3.0",
|
|
82
82
|
"superagent": "^7.1.3",
|
|
83
83
|
"uuid": "^8.3.1",
|
|
84
|
-
"xdg-basedir": "^4.0.0"
|
|
85
|
-
"yargs": "^15.4.1"
|
|
84
|
+
"xdg-basedir": "^4.0.0"
|
|
86
85
|
},
|
|
87
86
|
"devDependencies": {
|
|
88
|
-
"@
|
|
89
|
-
"@babel/core": "^7.12.3",
|
|
90
|
-
"@babel/plugin-transform-runtime": "^7.12.1",
|
|
91
|
-
"@babel/preset-env": "^7.11.5",
|
|
92
|
-
"@babel/register": "^7.12.1",
|
|
87
|
+
"@todesktop/shared": "^7.147.0",
|
|
93
88
|
"@types/bunyan": "^1.8.6",
|
|
89
|
+
"@types/react": "^18.0.26",
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
|
91
|
+
"@typescript-eslint/parser": "^5.46.1",
|
|
94
92
|
"ava": "^4.3.1",
|
|
95
|
-
"babel-preset-es2015": "^6.24.1",
|
|
96
93
|
"cp-cli": "^2.0.0",
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"eslint
|
|
100
|
-
"eslint-config-
|
|
101
|
-
"eslint-plugin-import": "^2.
|
|
94
|
+
"esbuild": "^0.16.5",
|
|
95
|
+
"esbuild-register": "^3.4.1",
|
|
96
|
+
"eslint": "^8.29.0",
|
|
97
|
+
"eslint-config-prettier": "^8.5.0",
|
|
98
|
+
"eslint-plugin-import": "^2.26.0",
|
|
102
99
|
"eslint-plugin-node": "^11.1.0",
|
|
103
|
-
"eslint-plugin-prettier": "^
|
|
104
|
-
"eslint-plugin-promise": "^
|
|
105
|
-
"eslint-plugin-react": "^7.
|
|
106
|
-
"eslint-plugin-react-hooks": "^4.
|
|
107
|
-
"eslint-plugin-standard": "^4.0
|
|
100
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
101
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
102
|
+
"eslint-plugin-react": "^7.31.11",
|
|
103
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
104
|
+
"eslint-plugin-standard": "^4.1.0",
|
|
108
105
|
"execa": "^4.0.3",
|
|
109
106
|
"extract-zip": "^2.0.1",
|
|
110
107
|
"fs-extra": "^9.0.1",
|
|
111
108
|
"husky": "^4.3.0",
|
|
112
109
|
"lint-staged": "^10.2.11",
|
|
113
|
-
"
|
|
114
|
-
"prettier": "^2.1.2",
|
|
110
|
+
"prettier": "^2.8.1",
|
|
115
111
|
"proxyquire": "^2.1.3",
|
|
116
|
-
"sinon": "^9.0.3"
|
|
112
|
+
"sinon": "^9.0.3",
|
|
113
|
+
"typescript": "^4.9.4"
|
|
117
114
|
},
|
|
118
115
|
"ava": {
|
|
116
|
+
"extensions": [
|
|
117
|
+
"ts"
|
|
118
|
+
],
|
|
119
119
|
"files": [
|
|
120
|
-
"test/**/*.
|
|
120
|
+
"test/**/*.ts",
|
|
121
121
|
"!test/fixtures/**/*",
|
|
122
122
|
"!test/utilities/**/*"
|
|
123
123
|
],
|
|
124
124
|
"require": [
|
|
125
|
-
"
|
|
125
|
+
"esbuild-register"
|
|
126
126
|
],
|
|
127
127
|
"timeout": "10m"
|
|
128
128
|
},
|
|
129
129
|
"lint-staged": {
|
|
130
|
-
"**/*.js": [
|
|
131
|
-
"eslint
|
|
130
|
+
"**/*.{js,ts,tsx}": [
|
|
131
|
+
"eslint src --fix",
|
|
132
132
|
"git add"
|
|
133
133
|
]
|
|
134
134
|
},
|
package/build/boot.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const camelcaseKeys = require('camelcase-keys');
|
|
4
|
-
const decamelize = require('decamelize');
|
|
5
|
-
const yargs = require('yargs');
|
|
6
|
-
|
|
7
|
-
const getCommandsMessage = command => {
|
|
8
|
-
const usageString = [...command.usage, command.name].join(' ');
|
|
9
|
-
return `Commands:\n${command.subCommands.map(subCommand => ` ${usageString} ${subCommand.name}`).join('\n')}\n`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
module.exports = (dirname, React, Ink, originalCommands) => {
|
|
13
|
-
let commands = originalCommands;
|
|
14
|
-
|
|
15
|
-
// For backwards compatibility for builds made with versions prior to 1.1.0 that don't include positionalArgs
|
|
16
|
-
if (originalCommands.some(command => !command.positionalArgs && (command.args || []).some(arg => arg.positional))) {
|
|
17
|
-
commands = originalCommands.map(command => ({
|
|
18
|
-
...command,
|
|
19
|
-
positionalArgs: (command.args || []).filter(arg => arg.positional).map(arg => arg.key)
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const addCommand = (command, yargs) => {
|
|
24
|
-
// Don't need to add a description as it'll be handled by the * selector in the builder
|
|
25
|
-
// eslint-disable-next-line no-use-before-define
|
|
26
|
-
yargs.command(command.name, '', builder.bind(null, command), () => yargs.showHelp());
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const handler = (command, argv) => {
|
|
30
|
-
const props = {
|
|
31
|
-
...camelcaseKeys(argv),
|
|
32
|
-
inputArgs: argv._
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const UI = require(path.join(dirname, 'commands', command.path.replace('.tsx', '.js'))).default;
|
|
36
|
-
const {waitUntilExit} = Ink.render(React.createElement(UI, props));
|
|
37
|
-
|
|
38
|
-
waitUntilExit().catch(error => {
|
|
39
|
-
console.error(error.stack);
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const builder = (command, yargs) => {
|
|
44
|
-
const {
|
|
45
|
-
positionalArgs = [],
|
|
46
|
-
args,
|
|
47
|
-
description,
|
|
48
|
-
name,
|
|
49
|
-
subCommands,
|
|
50
|
-
isDefaultIndex,
|
|
51
|
-
usage
|
|
52
|
-
} = command;
|
|
53
|
-
|
|
54
|
-
for (const subCommand of subCommands) {
|
|
55
|
-
addCommand({
|
|
56
|
-
...subCommand,
|
|
57
|
-
usage: [...usage, name]
|
|
58
|
-
}, yargs);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// If there is no index defined, yargs will just list the sub-commands
|
|
62
|
-
if (isDefaultIndex) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const hasPositionalArgs = positionalArgs.length > 0;
|
|
67
|
-
const positionalArgsString = positionalArgs.map(key => {
|
|
68
|
-
const {isRequired, type, aliases} = args.find(arg => arg.key === key);
|
|
69
|
-
const [startTag, endTag] = isRequired ? ['<', '>'] : ['[', type === 'array' ? '..]' : ']'];
|
|
70
|
-
const argsNames = [key, ...aliases.slice(0, 1)].map(name => decamelize(name, '-')).join('|');
|
|
71
|
-
|
|
72
|
-
return `${startTag}${argsNames}${endTag}`;
|
|
73
|
-
}).join(' ');
|
|
74
|
-
|
|
75
|
-
const yargsName = hasPositionalArgs ? `* ${positionalArgsString}` : '*';
|
|
76
|
-
const commandDescription = description || `${name} command`;
|
|
77
|
-
|
|
78
|
-
yargs.command(yargsName, commandDescription, scopedYargs => {
|
|
79
|
-
for (const arg of command.args) {
|
|
80
|
-
// `inputArgs` is a reserved prop by Pastel and doesn't require a definition in yargs
|
|
81
|
-
if (arg.key === 'inputArgs') {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (arg.positional) {
|
|
86
|
-
scopedYargs.positional(decamelize(arg.key, '-'), {
|
|
87
|
-
type: arg.type,
|
|
88
|
-
description: arg.description,
|
|
89
|
-
default: arg.defaultValue,
|
|
90
|
-
// This only keeps one for some reason for positional arguments
|
|
91
|
-
// The slice ensures we keep the same as the one we add in the command
|
|
92
|
-
alias: arg.aliases.slice(0, 1).map(alias => decamelize(alias, '-'))
|
|
93
|
-
});
|
|
94
|
-
} else {
|
|
95
|
-
scopedYargs.option(decamelize(arg.key, '-'), {
|
|
96
|
-
type: arg.type,
|
|
97
|
-
description: arg.description,
|
|
98
|
-
default: arg.defaultValue,
|
|
99
|
-
demandOption: arg.isRequired,
|
|
100
|
-
alias: arg.aliases.map(alias => decamelize(alias, '-'))
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// If the index command takes no arguments and there are available sub-commands,
|
|
106
|
-
// list the sub-commands in the help message.
|
|
107
|
-
if (!hasPositionalArgs && subCommands.length > 0) {
|
|
108
|
-
const usageMessage = getCommandsMessage(command);
|
|
109
|
-
scopedYargs.demandCommand(0, 0, usageMessage, usageMessage);
|
|
110
|
-
}
|
|
111
|
-
}, handler.bind(null, command));
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
yargs.command(
|
|
115
|
-
'*', '',
|
|
116
|
-
yargs => {
|
|
117
|
-
const usage = [path.basename(yargs.$0)];
|
|
118
|
-
for (const command of commands) {
|
|
119
|
-
addCommand({...command, usage}, yargs);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
() => yargs.showHelp()
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
yargs.parse();
|
|
126
|
-
};
|
package/build/cli.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
const React = require('react'); // eslint-disable-line import/no-unresolved
|
|
4
|
-
const Ink = require('ink'); // eslint-disable-line import/no-unresolved
|
|
5
|
-
const boot = require('./boot'); // eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved
|
|
6
|
-
const {commands} = require('./commands.json'); // eslint-disable-line import/no-unresolved
|
|
7
|
-
|
|
8
|
-
// This file is an entrypoint of CLI applications based on Pastel
|
|
9
|
-
// This file is copied to "build" directory of the CLI and "bin" field
|
|
10
|
-
// in package.json must point to it
|
|
11
|
-
boot(__dirname, React, Ink, commands);
|
package/build/cli.js.bak
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
const React = require('react'); // eslint-disable-line import/no-unresolved
|
|
4
|
-
const Ink = require('ink'); // eslint-disable-line import/no-unresolved
|
|
5
|
-
const boot = require('pastel/boot'); // eslint-disable-line import/no-extraneous-dependencies, import/no-unresolved
|
|
6
|
-
const {commands} = require('./commands.json'); // eslint-disable-line import/no-unresolved
|
|
7
|
-
|
|
8
|
-
// This file is an entrypoint of CLI applications based on Pastel
|
|
9
|
-
// This file is copied to "build" directory of the CLI and "bin" field
|
|
10
|
-
// in package.json must point to it
|
|
11
|
-
boot(__dirname, React, Ink, commands);
|