@youcan/cli 1.0.8 → 1.1.0-beta.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/bin/exec.cmd +3 -0
- package/bin/exec.js +8 -0
- package/dist/cli/commands/auth/login.d.ts +4 -2
- package/dist/cli/commands/auth/login.js +7 -85
- package/dist/cli/commands/auth/logout.d.ts +4 -2
- package/dist/cli/commands/auth/logout.js +9 -18
- package/dist/index.d.ts +2 -1
- package/dist/index.js +20 -2
- package/package.json +56 -38
- package/bin/index.js +0 -2
- package/dist/cli/commands/apps/create.d.ts +0 -2
- package/dist/cli/commands/apps/create.js +0 -65
- package/dist/cli/commands/apps/install.d.ts +0 -2
- package/dist/cli/commands/apps/install.js +0 -28
- package/dist/cli/commands/auth/types.d.ts +0 -6
- package/dist/cli/commands/index.d.ts +0 -12
- package/dist/cli/commands/index.js +0 -14
- package/dist/cli/commands/store/info.d.ts +0 -2
- package/dist/cli/commands/store/info.js +0 -29
- package/dist/cli/commands/store/switch.d.ts +0 -2
- package/dist/cli/commands/store/switch.js +0 -59
- package/dist/cli/commands/store/types.d.ts +0 -4
- package/dist/cli/commands/theme/delete.d.ts +0 -2
- package/dist/cli/commands/theme/delete.js +0 -46
- package/dist/cli/commands/theme/dev.d.ts +0 -2
- package/dist/cli/commands/theme/dev.js +0 -199
- package/dist/cli/commands/theme/init.d.ts +0 -2
- package/dist/cli/commands/theme/init.js +0 -86
- package/dist/cli/commands/theme/list.d.ts +0 -2
- package/dist/cli/commands/theme/list.js +0 -35
- package/dist/cli/commands/theme/pack.d.ts +0 -2
- package/dist/cli/commands/theme/pack.js +0 -31
- package/dist/cli/commands/theme/pull.d.ts +0 -2
- package/dist/cli/commands/theme/pull.js +0 -56
- package/dist/cli/commands/theme/types.d.ts +0 -17
- package/dist/cli/commands/types.d.ts +0 -22
- package/dist/cli/index.d.ts +0 -12
- package/dist/cli/index.js +0 -53
- package/dist/config/index.d.ts +0 -21
- package/dist/config/index.js +0 -25
- package/dist/config/messages.d.ts +0 -36
- package/dist/config/messages.js +0 -37
- package/dist/core/client/client.d.ts +0 -23
- package/dist/core/client/client.js +0 -83
- package/dist/core/client/types.d.ts +0 -80
- package/dist/core/themes/preview.d.ts +0 -1
- package/dist/core/themes/preview.js +0 -37
- package/dist/lib/cli/commands/apps/create.d.ts +0 -2
- package/dist/lib/cli/commands/apps/install.d.ts +0 -2
- package/dist/lib/cli/commands/auth/login.d.ts +0 -2
- package/dist/lib/cli/commands/auth/logout.d.ts +0 -2
- package/dist/lib/cli/commands/auth/types.d.ts +0 -6
- package/dist/lib/cli/commands/index.d.ts +0 -12
- package/dist/lib/cli/commands/store/info.d.ts +0 -2
- package/dist/lib/cli/commands/store/switch.d.ts +0 -2
- package/dist/lib/cli/commands/store/types.d.ts +0 -4
- package/dist/lib/cli/commands/theme/delete.d.ts +0 -2
- package/dist/lib/cli/commands/theme/dev.d.ts +0 -2
- package/dist/lib/cli/commands/theme/init.d.ts +0 -2
- package/dist/lib/cli/commands/theme/list.d.ts +0 -2
- package/dist/lib/cli/commands/theme/pack.d.ts +0 -2
- package/dist/lib/cli/commands/theme/pull.d.ts +0 -2
- package/dist/lib/cli/commands/theme/types.d.ts +0 -17
- package/dist/lib/cli/commands/types.d.ts +0 -22
- package/dist/lib/cli/index.d.ts +0 -12
- package/dist/lib/config/index.d.ts +0 -21
- package/dist/lib/config/messages.d.ts +0 -36
- package/dist/lib/core/client/client.d.ts +0 -23
- package/dist/lib/core/client/types.d.ts +0 -80
- package/dist/lib/core/themes/preview.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/utils/common.d.ts +0 -22
- package/dist/lib/utils/git/cloneRepository.d.ts +0 -6
- package/dist/lib/utils/helpers.d.ts +0 -3
- package/dist/lib/utils/http.d.ts +0 -11
- package/dist/lib/utils/network.d.ts +0 -2
- package/dist/lib/utils/system/deleteFile.d.ts +0 -5
- package/dist/lib/utils/system/ls.d.ts +0 -1
- package/dist/lib/utils/system/openLink.d.ts +0 -1
- package/dist/lib/utils/system/saveFile.d.ts +0 -1
- package/dist/lib/utils/system/stdout.d.ts +0 -20
- package/dist/lib/utils/system/writeToFile.d.ts +0 -6
- package/dist/lib/utils/system/zipFolder.d.ts +0 -5
- package/dist/lib/utils/system.d.ts +0 -1
- package/dist/test/commands/auth/login.d.ts +0 -2
- package/dist/test/commands/auth/logout.d.ts +0 -2
- package/dist/test/commands/help.d.ts +0 -2
- package/dist/test/commands/theme/delete.d.ts +0 -2
- package/dist/test/commands/theme/dev.d.ts +0 -2
- package/dist/test/commands/theme/init.d.ts +0 -2
- package/dist/test/index.test.d.ts +0 -1
- package/dist/utils/common.d.ts +0 -22
- package/dist/utils/common.js +0 -67
- package/dist/utils/git/cloneRepository.d.ts +0 -6
- package/dist/utils/git/cloneRepository.js +0 -18
- package/dist/utils/helpers.d.ts +0 -3
- package/dist/utils/helpers.js +0 -35
- package/dist/utils/http.d.ts +0 -11
- package/dist/utils/http.js +0 -26
- package/dist/utils/network.d.ts +0 -2
- package/dist/utils/network.js +0 -81
- package/dist/utils/system/deleteFile.d.ts +0 -5
- package/dist/utils/system/deleteFile.js +0 -13
- package/dist/utils/system/ls.d.ts +0 -1
- package/dist/utils/system/ls.js +0 -9
- package/dist/utils/system/openLink.d.ts +0 -1
- package/dist/utils/system/saveFile.d.ts +0 -1
- package/dist/utils/system/saveFile.js +0 -9
- package/dist/utils/system/stdout.d.ts +0 -17
- package/dist/utils/system/stdout.js +0 -35
- package/dist/utils/system/writeToFile.d.ts +0 -1
- package/dist/utils/system/writeToFile.js +0 -7
- package/dist/utils/system/zipFolder.d.ts +0 -5
- package/dist/utils/system/zipFolder.js +0 -57
- package/dist/utils/system.d.ts +0 -1
- package/dist/utils/system.js +0 -18
package/bin/exec.cmd
ADDED
package/bin/exec.js
ADDED
|
@@ -1,88 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import prompts from 'prompts';
|
|
3
|
-
import config from '../../../config/index.js';
|
|
4
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
5
|
-
import writeToFile from '../../../utils/system/writeToFile.js';
|
|
6
|
-
import messages from '../../../config/messages.js';
|
|
7
|
-
import { isPortAvailable, getPidByPort } from '../../../utils/network.js';
|
|
8
|
-
import { kill } from '../../../utils/system.js';
|
|
9
|
-
import { LoadingSpinner } from '../../../utils/common.js';
|
|
1
|
+
import { Cli, Session } from '@youcan/cli-kit';
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
action: async () => {
|
|
17
|
-
if (!(await isPortAvailable(config.OAUTH_CALLBACK_PORT))) {
|
|
18
|
-
stdout.warn(`YouCan CLI requires that the port ${config.OAUTH_CALLBACK_PORT} be available`);
|
|
19
|
-
const prompt = await prompts({
|
|
20
|
-
initial: false,
|
|
21
|
-
type: 'confirm',
|
|
22
|
-
name: 'terminate',
|
|
23
|
-
message: 'Terminate the process to free the port?',
|
|
24
|
-
});
|
|
25
|
-
if (!prompt.terminate) {
|
|
26
|
-
stdout.log('Exiting..');
|
|
27
|
-
exit(1);
|
|
28
|
-
}
|
|
29
|
-
const pid = await getPidByPort(config.OAUTH_CALLBACK_PORT);
|
|
30
|
-
if (pid) {
|
|
31
|
-
await LoadingSpinner.exec(`Terminating process ${pid}..`, async (spinner) => {
|
|
32
|
-
try {
|
|
33
|
-
await kill(pid, 'SIGTERM', 30_000);
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
spinner.error('Could not terminate process, proceeding..');
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const loading = new LoadingSpinner('Authenticating...');
|
|
42
|
-
try {
|
|
43
|
-
const inquiries = [
|
|
44
|
-
{
|
|
45
|
-
type: 'text',
|
|
46
|
-
name: 'email',
|
|
47
|
-
message: 'Type your email',
|
|
48
|
-
validate: value => value !== '',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: 'password',
|
|
52
|
-
name: 'password',
|
|
53
|
-
message: 'Type your password',
|
|
54
|
-
validate: value => value !== '',
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
const credentials = await prompts(inquiries);
|
|
58
|
-
loading.start();
|
|
59
|
-
const response = await cli.client.auth({ email: credentials.email, password: credentials.password });
|
|
60
|
-
let token = response.token;
|
|
61
|
-
loading.stop();
|
|
62
|
-
cli.client.setAccessToken(response.token);
|
|
63
|
-
if (response.stores.length > 1) {
|
|
64
|
-
const choices = response.stores.map(store => ({
|
|
65
|
-
title: store.slug,
|
|
66
|
-
value: store.store_id,
|
|
67
|
-
}));
|
|
68
|
-
const { storeId } = await prompts({
|
|
69
|
-
type: 'select',
|
|
70
|
-
name: 'storeId',
|
|
71
|
-
message: messages.SELECT_STORE,
|
|
72
|
-
choices,
|
|
73
|
-
});
|
|
74
|
-
const selectStoreResponse = await cli.client.selectStore({ id: storeId });
|
|
75
|
-
token = selectStoreResponse.token;
|
|
76
|
-
}
|
|
77
|
-
writeToFile(config.CLI_GLOBAL_CONFIG_PATH, JSON.stringify({ access_token: token }));
|
|
78
|
-
stdout.info(messages.LOGIN_SUCCESS);
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
const error = JSON.parse(err.message);
|
|
82
|
-
loading.error(error.detail);
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
};
|
|
3
|
+
class Login extends Cli.Command {
|
|
4
|
+
async run() {
|
|
5
|
+
const session = await Session.authenticate(this);
|
|
6
|
+
this.output.info(`Logged in as ${session.slug}`);
|
|
7
|
+
}
|
|
86
8
|
}
|
|
87
9
|
|
|
88
|
-
export {
|
|
10
|
+
export { Login as default };
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import messages from '../../../config/messages.js';
|
|
3
|
-
import deleteFile from '../../../utils/system/deleteFile.js';
|
|
4
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
1
|
+
import { Cli, Config } from '@youcan/cli-kit';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return stdout.error(messages.AUTH_USER_NOT_LOGGED_IN);
|
|
14
|
-
}
|
|
15
|
-
deleteFile(config.CLI_GLOBAL_CONFIG_PATH);
|
|
16
|
-
stdout.info(messages.AUTH_USER_LOGGED_OUT);
|
|
17
|
-
},
|
|
18
|
-
};
|
|
3
|
+
class Login extends Cli.Command {
|
|
4
|
+
async run() {
|
|
5
|
+
Config
|
|
6
|
+
.manager({ projectName: 'youcan-cli' })
|
|
7
|
+
.delete('store_session');
|
|
8
|
+
return this.output.info('Successfully logged out..');
|
|
9
|
+
}
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
export {
|
|
12
|
+
export { Login as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
declare function execCli(development: boolean): Promise<void>;
|
|
2
|
+
export default execCli;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { Cli } from '@youcan/cli-kit';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
process.on('uncaughtException', (err) => {
|
|
5
|
+
fs.writeSync(process.stderr.fd, `${err.stack}\n`);
|
|
6
|
+
process.exit(1);
|
|
7
|
+
});
|
|
8
|
+
const signals = ['SIGINT', 'SIGTERM', 'SIGQUIT'];
|
|
9
|
+
signals.forEach((signal) => {
|
|
10
|
+
process.on(signal, () => {
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
async function execCli(development) {
|
|
15
|
+
await Cli.exec({
|
|
16
|
+
moduleUrl: import.meta.url,
|
|
17
|
+
development,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { execCli as default };
|
package/package.json
CHANGED
|
@@ -1,61 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youcan/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.1.0-beta.2",
|
|
5
|
+
"description": "A CLI for creating YouCan Shop apps",
|
|
6
6
|
"author": "YouCan <contact@youcan.shop> (https://youcan.shop)",
|
|
7
|
-
"
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/youcan-shop/cli#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/youcan-shop/cli/edit/main/packages/cli"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"youcan",
|
|
15
|
+
"youcan-cli",
|
|
16
|
+
"youcan-app"
|
|
17
|
+
],
|
|
8
18
|
"exports": {
|
|
9
19
|
".": {
|
|
10
|
-
"
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
11
21
|
"import": "./dist/index.js"
|
|
12
22
|
}
|
|
13
23
|
},
|
|
14
24
|
"main": "./dist/index.js",
|
|
15
|
-
"types": "./dist/dts/index.d.ts",
|
|
16
25
|
"bin": {
|
|
17
|
-
"youcan": "bin/
|
|
26
|
+
"youcan": "./bin/exec.js"
|
|
18
27
|
},
|
|
19
28
|
"files": [
|
|
20
|
-
"
|
|
21
|
-
"
|
|
29
|
+
"/dist",
|
|
30
|
+
"/bin/exec.js",
|
|
31
|
+
"/bin/exec.cmd",
|
|
32
|
+
"/oclif.manifest.json"
|
|
22
33
|
],
|
|
23
34
|
"dependencies": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"node-fetch": "^3.3.2",
|
|
32
|
-
"prompts": "^2.4.2",
|
|
33
|
-
"puppeteer": "^19.11.1",
|
|
34
|
-
"ramda": "^0.28.0",
|
|
35
|
-
"socket.io": "^4.7.2",
|
|
36
|
-
"socket.io-client": "^4.7.2"
|
|
35
|
+
"@oclif/core": "^2.15.0",
|
|
36
|
+
"@oclif/plugin-commands": "^2.2.26",
|
|
37
|
+
"@oclif/plugin-help": "^5.2.19",
|
|
38
|
+
"@oclif/plugin-plugins": "^3.8.2",
|
|
39
|
+
"@youcan/app": "1.1.0-beta.2",
|
|
40
|
+
"@youcan/cli-kit": "1.1.0-beta.2",
|
|
41
|
+
"@youcan/theme": "1.1.0-beta.2"
|
|
37
42
|
},
|
|
38
43
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@azuradara/eslint-config-ts": "^0.1.3",
|
|
41
|
-
"@types/archiver": "^5.3.3",
|
|
42
|
-
"@types/file-saver": "^2.0.5",
|
|
44
|
+
"@oclif/plugin-legacy": "^1.3.0",
|
|
43
45
|
"@types/node": "^18.18.0",
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
"shx": "^0.3.4"
|
|
47
|
+
},
|
|
48
|
+
"oclif": {
|
|
49
|
+
"bin": "youcan",
|
|
50
|
+
"scope": "youcan",
|
|
51
|
+
"commands": "./dist/cli/commands",
|
|
52
|
+
"plugins": [
|
|
53
|
+
"@youcan/app",
|
|
54
|
+
"@youcan/theme",
|
|
55
|
+
"@oclif/plugin-help",
|
|
56
|
+
"@oclif/plugin-commands"
|
|
57
|
+
],
|
|
58
|
+
"topicSeparator": " ",
|
|
59
|
+
"topics": {
|
|
60
|
+
"theme": {
|
|
61
|
+
"description": "Build YouCan themes."
|
|
62
|
+
},
|
|
63
|
+
"app": {
|
|
64
|
+
"description": "Build YouCan apps."
|
|
65
|
+
},
|
|
66
|
+
"auth": {
|
|
67
|
+
"description": "Authenticate with your YouCan account."
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"additionalHelpFlags": [
|
|
71
|
+
"-h"
|
|
72
|
+
]
|
|
55
73
|
},
|
|
56
74
|
"scripts": {
|
|
57
|
-
"build": "tsc --noEmit && rollup --config rollup.config.js",
|
|
58
|
-
"dev": "rollup --config rollup.config.js --watch",
|
|
75
|
+
"build": "shx rm -rf dist && tsc --noEmit && rollup --config rollup.config.js",
|
|
76
|
+
"dev": "shx rm -rf dist && rollup --config rollup.config.js --watch",
|
|
59
77
|
"release": "pnpm publish --access public",
|
|
60
78
|
"type-check": "tsc --noEmit",
|
|
61
79
|
"relink": "pnpm link --global"
|
package/bin/index.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import prompts from 'prompts';
|
|
3
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
4
|
-
import messages from '../../../config/messages.js';
|
|
5
|
-
import { LoadingSpinner } from '../../../utils/common.js';
|
|
6
|
-
|
|
7
|
-
function command(cli) {
|
|
8
|
-
return {
|
|
9
|
-
name: 'apps:create',
|
|
10
|
-
group: 'apps',
|
|
11
|
-
description: 'Create your app',
|
|
12
|
-
action: async () => {
|
|
13
|
-
if (!cli.client.isAuthenticated()) {
|
|
14
|
-
return stdout.error(messages.AUTH_USER_NOT_LOGGED_IN);
|
|
15
|
-
}
|
|
16
|
-
const loading = new LoadingSpinner('Creating your app ...');
|
|
17
|
-
try {
|
|
18
|
-
const inquiries = [
|
|
19
|
-
{
|
|
20
|
-
type: 'text',
|
|
21
|
-
name: 'name',
|
|
22
|
-
message: 'Type your app name',
|
|
23
|
-
validate: value => value !== '' && value.length > 3,
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
const app = await prompts(inquiries);
|
|
27
|
-
loading.start();
|
|
28
|
-
await cli.client.createApp({ name: app.name });
|
|
29
|
-
const appPath = `./${app.name}`;
|
|
30
|
-
fs.mkdir(appPath, (err) => {
|
|
31
|
-
if (err) {
|
|
32
|
-
loading.error(`Error creating directory: ${err}`);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const packageContent = {
|
|
36
|
-
name: app.name,
|
|
37
|
-
version: '0.0.1',
|
|
38
|
-
description: 'Your package description',
|
|
39
|
-
main: 'index.js',
|
|
40
|
-
scripts: {
|
|
41
|
-
start: `node index.js && youcan apps:install -n ${app.name}`,
|
|
42
|
-
},
|
|
43
|
-
dependencies: {},
|
|
44
|
-
};
|
|
45
|
-
fs.writeFile(`${appPath}/package.json`, JSON.stringify(packageContent, null, 2), (err) => {
|
|
46
|
-
if (err) {
|
|
47
|
-
stdout.error(`Error creating the package.json file: ${err}`);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
fs.writeFile(`${appPath}/index.js`, 'console.log(\'Hello, World!\')', (err) => {
|
|
51
|
-
if (err) {
|
|
52
|
-
stdout.error(`Error creating the index.js file: ${err}`);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
loading.stop();
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
const error = JSON.parse(err.message);
|
|
59
|
-
loading.error(error.detail);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { command as default };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
2
|
-
import messages from '../../../config/messages.js';
|
|
3
|
-
|
|
4
|
-
function command(cli) {
|
|
5
|
-
return {
|
|
6
|
-
name: 'apps:install',
|
|
7
|
-
group: 'apps',
|
|
8
|
-
description: 'Generate app installation url',
|
|
9
|
-
options: [
|
|
10
|
-
{ name: '-n, --name <app>', description: 'Specify a app name e.g. codmanager' },
|
|
11
|
-
],
|
|
12
|
-
action: async (options) => {
|
|
13
|
-
if (!cli.client.isAuthenticated()) {
|
|
14
|
-
return stdout.error(messages.AUTH_USER_NOT_LOGGED_IN);
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
const response = await cli.client.generateAppInstallationUrl(options.name);
|
|
18
|
-
stdout.info(`To test the app within your store hit the following url : ${response.url}`);
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
const error = JSON.parse(err.message);
|
|
22
|
-
stdout.error(error);
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { command as default };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { default as LoginCommand } from './auth/login';
|
|
2
|
-
export { default as LogoutCommand } from './auth/logout';
|
|
3
|
-
export { default as ThemeInitCommand } from './theme/init';
|
|
4
|
-
export { default as ThemeListCommand } from './theme/list';
|
|
5
|
-
export { default as ThemeDevCommand } from './theme/dev';
|
|
6
|
-
export { default as ThemeDeleteCommand } from './theme/delete';
|
|
7
|
-
export { default as ThemePullCommand } from './theme/pull';
|
|
8
|
-
export { default as ThemePackCommand } from './theme/pack';
|
|
9
|
-
export { default as StoreInfoCommand } from './store/info';
|
|
10
|
-
export { default as StoreSwitchCommand } from './store/switch';
|
|
11
|
-
export { default as CreateAppCommand } from './apps/create';
|
|
12
|
-
export { default as InstallAppCommand } from './apps/install';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export { default as LoginCommand } from './auth/login.js';
|
|
2
|
-
export { default as LogoutCommand } from './auth/logout.js';
|
|
3
|
-
export { default as ThemeInitCommand } from './theme/init.js';
|
|
4
|
-
export { default as ThemeListCommand } from './theme/list.js';
|
|
5
|
-
export { default as ThemeDevCommand } from './theme/dev.js';
|
|
6
|
-
export { default as ThemeDeleteCommand } from './theme/delete.js';
|
|
7
|
-
export { default as ThemePullCommand } from './theme/pull.js';
|
|
8
|
-
export { default as ThemePackCommand } from './theme/pack.js';
|
|
9
|
-
export { default as StoreInfoCommand } from './store/info.js';
|
|
10
|
-
export { default as StoreSwitchCommand } from './store/switch.js';
|
|
11
|
-
export { default as CreateAppCommand } from './apps/create.js';
|
|
12
|
-
export { default as InstallAppCommand } from './apps/install.js';
|
|
13
|
-
|
|
14
|
-
// auth
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import messages from '../../../config/messages.js';
|
|
2
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
3
|
-
import { LoadingSpinner } from '../../../utils/common.js';
|
|
4
|
-
|
|
5
|
-
function command(cli) {
|
|
6
|
-
return {
|
|
7
|
-
name: 'store:info',
|
|
8
|
-
group: 'theme',
|
|
9
|
-
description: 'Current development store info',
|
|
10
|
-
options: [],
|
|
11
|
-
action: async () => {
|
|
12
|
-
if (!cli.client.isAuthenticated()) {
|
|
13
|
-
return stdout.error(messages.AUTH_USER_NOT_LOGGED_IN);
|
|
14
|
-
}
|
|
15
|
-
await LoadingSpinner.exec(`${messages.FETCHING_CURRENT_STORE_INFO}..`, async (spinner) => {
|
|
16
|
-
try {
|
|
17
|
-
const storeInfo = await cli.client.getStoreInfo();
|
|
18
|
-
spinner.stop();
|
|
19
|
-
stdout.info(`${messages.CURRENT_DEVELOPMENT_STORE}: ${storeInfo.slug}`);
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
spinner.error(messages.ERROR_WHILE_FETCHING_CURRENT_STORE_INFO);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export { command as default };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import messages from '../../../config/messages.js';
|
|
3
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
4
|
-
import { LoadingSpinner } from '../../../utils/common.js';
|
|
5
|
-
import writeToFile from '../../../utils/system/writeToFile.js';
|
|
6
|
-
import config from '../../../config/index.js';
|
|
7
|
-
|
|
8
|
-
function command(cli) {
|
|
9
|
-
return {
|
|
10
|
-
name: 'store:switch',
|
|
11
|
-
group: 'theme',
|
|
12
|
-
description: 'Switch the development store',
|
|
13
|
-
options: [],
|
|
14
|
-
action: async () => {
|
|
15
|
-
if (!cli.client.isAuthenticated()) {
|
|
16
|
-
return stdout.error(messages.AUTH_USER_NOT_LOGGED_IN);
|
|
17
|
-
}
|
|
18
|
-
let storeInfo;
|
|
19
|
-
await LoadingSpinner.exec(`${messages.FETCHING_CURRENT_STORE_INFO}..`, async (spinner) => {
|
|
20
|
-
try {
|
|
21
|
-
storeInfo = await cli.client.getStoreInfo();
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
spinner.error(messages.ERROR_WHILE_FETCHING_CURRENT_STORE_INFO);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
stdout.info(`${messages.CURRENT_DEVELOPMENT_STORE}: ${storeInfo.slug}`);
|
|
28
|
-
const { stores } = await cli.client.listStores();
|
|
29
|
-
if (!stores.length) {
|
|
30
|
-
return stdout.error(messages.NO_STORE_FOUND);
|
|
31
|
-
}
|
|
32
|
-
const choices = stores.map(store => ({
|
|
33
|
-
title: store.slug,
|
|
34
|
-
value: store.store_id,
|
|
35
|
-
}));
|
|
36
|
-
const { storeId } = await prompts({
|
|
37
|
-
type: 'select',
|
|
38
|
-
name: 'storeId',
|
|
39
|
-
message: messages.SELECT_STORE,
|
|
40
|
-
choices,
|
|
41
|
-
});
|
|
42
|
-
if (!storeId) {
|
|
43
|
-
return stdout.error(messages.NO_STORE_SELECTED);
|
|
44
|
-
}
|
|
45
|
-
await LoadingSpinner.exec(`${messages.SELECT_STORE_IN_PROGRESS}..`, async (spinner) => {
|
|
46
|
-
try {
|
|
47
|
-
const selectStoreResponse = await cli.client.selectStore({ id: storeId });
|
|
48
|
-
writeToFile(config.CLI_GLOBAL_CONFIG_PATH, JSON.stringify({ access_token: selectStoreResponse.token }));
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
spinner.error(messages.CANNOT_SELECT_STORE);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
stdout.info(messages.STORE_SELECTED);
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { command as default };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import prompts from 'prompts';
|
|
2
|
-
import messages from '../../../config/messages.js';
|
|
3
|
-
import stdout from '../../../utils/system/stdout.js';
|
|
4
|
-
import { LoadingSpinner } from '../../../utils/common.js';
|
|
5
|
-
|
|
6
|
-
function command(cli) {
|
|
7
|
-
return {
|
|
8
|
-
name: 'theme:delete',
|
|
9
|
-
group: 'theme',
|
|
10
|
-
description: 'Delete a remote development theme',
|
|
11
|
-
options: [],
|
|
12
|
-
action: async () => {
|
|
13
|
-
if (!cli.client.isAuthenticated()) {
|
|
14
|
-
return stdout.error(messages.AUTH_USER_NOT_LOGGED_IN);
|
|
15
|
-
}
|
|
16
|
-
const { dev: devThemes } = await cli.client.listThemes();
|
|
17
|
-
if (!devThemes.length) {
|
|
18
|
-
return stdout.error(messages.NO_REMOTE_THEMES);
|
|
19
|
-
}
|
|
20
|
-
const choices = devThemes.map(theme => ({
|
|
21
|
-
title: theme.name,
|
|
22
|
-
value: theme.id,
|
|
23
|
-
}));
|
|
24
|
-
const { themeId } = await prompts({
|
|
25
|
-
type: 'select',
|
|
26
|
-
name: 'themeId',
|
|
27
|
-
message: messages.DELETE_SELECT_THEME,
|
|
28
|
-
choices,
|
|
29
|
-
});
|
|
30
|
-
if (!themeId) {
|
|
31
|
-
return stdout.error(messages.DELETE_NO_THEME_SELECTED);
|
|
32
|
-
}
|
|
33
|
-
await LoadingSpinner.exec(`${messages.DELETE_IN_PROGRESS} ${themeId}..`, async (spinner) => {
|
|
34
|
-
try {
|
|
35
|
-
await cli.client.deleteTheme(themeId);
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
spinner.error(messages.DELETE_ERROR);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
stdout.info(messages.DELETE_THEME_DELETED);
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export { command as default };
|