@youcan/app 2.1.4 → 2.3.0
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/commands/app/dev.d.ts +13 -6
- package/dist/cli/commands/app/dev.js +89 -51
- package/dist/cli/commands/app/env/show.d.ts +7 -0
- package/dist/cli/commands/app/env/show.js +29 -0
- package/dist/cli/commands/app/generate/extension.d.ts +6 -6
- package/dist/cli/commands/app/generate/extension.js +50 -50
- package/dist/cli/commands/app/install.d.ts +5 -5
- package/dist/cli/commands/app/install.js +21 -21
- package/dist/cli/services/dev/workers/app-worker.d.ts +11 -10
- package/dist/cli/services/dev/workers/app-worker.js +29 -30
- package/dist/cli/services/dev/workers/index.d.ts +14 -10
- package/dist/cli/services/dev/workers/index.js +25 -19
- package/dist/cli/services/dev/workers/theme-extension-worker.d.ts +15 -15
- package/dist/cli/services/dev/workers/theme-extension-worker.js +113 -113
- package/dist/cli/services/dev/workers/tunnel-worker.d.ts +15 -0
- package/dist/cli/services/dev/workers/tunnel-worker.js +57 -0
- package/dist/cli/services/dev/workers/web-worker.d.ts +12 -11
- package/dist/cli/services/dev/workers/web-worker.js +26 -23
- package/dist/cli/services/generate/extensions/index.d.ts +2 -2
- package/dist/cli/services/generate/extensions/index.js +2 -2
- package/dist/cli/services/generate/extensions/theme-extension.d.ts +3 -3
- package/dist/cli/services/generate/extensions/theme-extension.js +17 -17
- package/dist/cli/services/generate/generate.d.ts +10 -10
- package/dist/cli/services/generate/generate.js +24 -24
- package/dist/constants.d.ts +5 -5
- package/dist/constants.js +4 -4
- package/dist/flags.d.ts +3 -3
- package/dist/flags.js +7 -7
- package/dist/types.d.ts +84 -69
- package/dist/util/app-command.d.ts +8 -0
- package/dist/util/app-command.js +41 -0
- package/dist/util/app-loader.d.ts +2 -2
- package/dist/util/app-loader.js +35 -35
- package/package.json +8 -3
- package/dist/util/theme-command.d.ts +0 -3
- package/dist/util/theme-command.js +0 -6
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { AppCommand } from '@/util/
|
|
2
|
-
declare class Dev extends AppCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { AppCommand } from '@/util/app-command';
|
|
2
|
+
declare class Dev extends AppCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
private readonly hotKeys;
|
|
5
|
+
run(): Promise<any>;
|
|
6
|
+
private prepareNetworkOptions;
|
|
7
|
+
reloadWorkers(): Promise<void>;
|
|
8
|
+
private runWorkers;
|
|
9
|
+
private prepareDevProcesses;
|
|
10
|
+
private buildEnvironmentVariables;
|
|
11
|
+
private openAppPreview;
|
|
12
|
+
}
|
|
13
|
+
export default Dev;
|
|
@@ -1,56 +1,94 @@
|
|
|
1
|
-
import { Session, Tasks,
|
|
2
|
-
import {
|
|
1
|
+
import { Session, Tasks, UI, System, Services, Env, Http } from '@youcan/cli-kit';
|
|
2
|
+
import { bootTunnelWorker, bootAppWorker, bootWebWorker, bootExtensionWorker } from '../../services/dev/workers/index.js';
|
|
3
|
+
import { AppCommand } from '../../../util/app-command.js';
|
|
3
4
|
import { load } from '../../../util/app-loader.js';
|
|
4
|
-
import { APP_CONFIG_FILENAME } from '../../../constants.js';
|
|
5
|
-
import { bootAppWorker, bootWebWorker, bootExtensionWorker } from '../../services/dev/workers/index.js';
|
|
6
5
|
|
|
7
|
-
class Dev extends AppCommand {
|
|
8
|
-
static description = 'Run the app in dev mode';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
6
|
+
class Dev extends AppCommand {
|
|
7
|
+
static description = 'Run the app in dev mode';
|
|
8
|
+
hotKeys = [
|
|
9
|
+
{
|
|
10
|
+
keyboardKey: 'p',
|
|
11
|
+
description: 'preview in your dev store',
|
|
12
|
+
handler: async () => this.openAppPreview(),
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
keyboardKey: 'q',
|
|
16
|
+
description: 'quit',
|
|
17
|
+
handler: () => this.exit(0),
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
async run() {
|
|
21
|
+
this.session = await Session.authenticate(this);
|
|
22
|
+
this.app = await load();
|
|
23
|
+
const { workers } = await Tasks.run({ cmd: this, workers: [] }, [
|
|
24
|
+
{
|
|
25
|
+
title: 'Preparing network options...',
|
|
26
|
+
task: async (ctx) => {
|
|
27
|
+
ctx.workers.push(await this.prepareNetworkOptions());
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: 'Syncing app configuration...',
|
|
32
|
+
task: async () => { await this.syncAppConfig(); },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'Preparing dev processes...',
|
|
36
|
+
task: async (ctx) => {
|
|
37
|
+
ctx.workers.push(...await this.prepareDevProcesses());
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
UI.renderDevOutput({ hotKeys: this.hotKeys, cmd: this });
|
|
42
|
+
this.runWorkers(workers);
|
|
43
|
+
}
|
|
44
|
+
async prepareNetworkOptions() {
|
|
45
|
+
const port = await System.getNextAvailablePort(3000);
|
|
46
|
+
// Start by `localhost` until a tunneled url is available
|
|
47
|
+
const appUrl = `http://localhost:${port}`;
|
|
48
|
+
this.app.networkConfig = { port, appUrl };
|
|
49
|
+
const worker = await bootTunnelWorker(this, this.app, new Services.Cloudflared());
|
|
50
|
+
return worker;
|
|
51
|
+
}
|
|
52
|
+
async reloadWorkers() {
|
|
53
|
+
this.controller = new AbortController();
|
|
54
|
+
// Preserve network config.
|
|
55
|
+
const networkConfig = this.app.networkConfig;
|
|
56
|
+
this.app = await load();
|
|
57
|
+
this.app.networkConfig = networkConfig;
|
|
58
|
+
await this.syncAppConfig();
|
|
59
|
+
await this.runWorkers(await this.prepareDevProcesses());
|
|
60
|
+
}
|
|
61
|
+
async runWorkers(workers) {
|
|
62
|
+
await Promise.all(workers.map(worker => worker.run())).catch((_) => { });
|
|
63
|
+
}
|
|
64
|
+
async prepareDevProcesses() {
|
|
65
|
+
const promises = [
|
|
66
|
+
bootAppWorker(this, this.app),
|
|
67
|
+
];
|
|
68
|
+
this.app.webs.forEach(web => promises.unshift(bootWebWorker(this, this.app, web, this.buildEnvironmentVariables())));
|
|
69
|
+
this.app.extensions.forEach(ext => promises.unshift(bootExtensionWorker(this, this.app, ext)));
|
|
70
|
+
return Promise.all(promises);
|
|
71
|
+
}
|
|
72
|
+
buildEnvironmentVariables() {
|
|
73
|
+
if (!this.app.remoteConfig) {
|
|
74
|
+
throw new Error('remote app config not loaded');
|
|
75
|
+
}
|
|
76
|
+
if (!this.app.networkConfig) {
|
|
77
|
+
throw new Error('app network config is not set');
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
YOUCAN_API_KEY: this.app.remoteConfig.client_id,
|
|
81
|
+
YOUCAN_API_SECRET: this.app.remoteConfig.client_secret,
|
|
82
|
+
YOUCAN_API_SCOPES: this.app.remoteConfig.scopes.join(','),
|
|
83
|
+
APP_URL: this.app.networkConfig.appUrl,
|
|
84
|
+
PORT: this.app.networkConfig.port.toString(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async openAppPreview() {
|
|
88
|
+
const endpointUrl = `${Env.apiHostname()}/apps/${this.app.config.id}/authorization-url`;
|
|
89
|
+
const { url } = await Http.get(endpointUrl);
|
|
90
|
+
System.open(url);
|
|
91
|
+
}
|
|
54
92
|
}
|
|
55
93
|
|
|
56
94
|
export { Dev as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Session, Tasks, Color } from '@youcan/cli-kit';
|
|
2
|
+
import { AppCommand } from '../../../../util/app-command.js';
|
|
3
|
+
import { load } from '../../../../util/app-loader.js';
|
|
4
|
+
|
|
5
|
+
class EnvShow extends AppCommand {
|
|
6
|
+
static description = 'Display app environment variables';
|
|
7
|
+
async run() {
|
|
8
|
+
this.app = await load();
|
|
9
|
+
this.session = await Session.authenticate(this);
|
|
10
|
+
await Tasks.run({}, [
|
|
11
|
+
{
|
|
12
|
+
title: 'Syncing app configuration..',
|
|
13
|
+
task: async () => { await this.syncAppConfig(); },
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
await this.printEnvironmentVariables();
|
|
17
|
+
}
|
|
18
|
+
async printEnvironmentVariables() {
|
|
19
|
+
if (!this.app.remoteConfig) {
|
|
20
|
+
throw new Error('remote app config not loaded');
|
|
21
|
+
}
|
|
22
|
+
this.log();
|
|
23
|
+
this.log(`${Color.yellow('YOUCAN_API_KEY')}=%s`, this.app.remoteConfig.client_id);
|
|
24
|
+
this.log(`${Color.yellow('YOUCAN_API_SECRET')}=%s`, this.app.remoteConfig.client_secret);
|
|
25
|
+
this.log(`${Color.yellow('YOUCAN_API_SCOPES')}=%s`, this.app.remoteConfig.scopes.join(','));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { EnvShow as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AppCommand } from '@/util/
|
|
2
|
-
declare class GenerateExtension extends AppCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
run(): Promise<any>;
|
|
5
|
-
}
|
|
6
|
-
export default GenerateExtension;
|
|
1
|
+
import { AppCommand } from '@/util/app-command';
|
|
2
|
+
declare class GenerateExtension extends AppCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
run(): Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export default GenerateExtension;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
import { Path, Filesystem, String, Tasks } from '@youcan/cli-kit';
|
|
2
|
-
import { AppCommand } from '../../../../util/
|
|
2
|
+
import { AppCommand } from '../../../../util/app-command.js';
|
|
3
3
|
import extensions from '../../../services/generate/extensions/index.js';
|
|
4
4
|
import { ensureExtensionDirectoryExists, initThemeExtension } from '../../../services/generate/generate.js';
|
|
5
5
|
import { APP_CONFIG_FILENAME } from '../../../../constants.js';
|
|
6
6
|
|
|
7
|
-
class GenerateExtension extends AppCommand {
|
|
8
|
-
static description = 'Generate an app extension';
|
|
9
|
-
async run() {
|
|
10
|
-
const filepath = Path.resolve(Path.cwd(), APP_CONFIG_FILENAME);
|
|
11
|
-
const app = await Filesystem.readJsonFile(filepath);
|
|
12
|
-
const { identifier } = await this.prompt({
|
|
13
|
-
name: 'identifier',
|
|
14
|
-
message: 'Extension type?',
|
|
15
|
-
type: 'select',
|
|
16
|
-
choices: extensions.map(ext => ({
|
|
17
|
-
title: ext.name,
|
|
18
|
-
value: ext.identifier,
|
|
19
|
-
description: ext.description,
|
|
20
|
-
})),
|
|
21
|
-
});
|
|
22
|
-
// TODO: prompt for extension type and flavor
|
|
23
|
-
const extension = extensions.find(ext => ext.identifier === identifier);
|
|
24
|
-
const type = extension.types[0];
|
|
25
|
-
const flavor = type.flavors[0];
|
|
26
|
-
const { name } = await this.prompt({
|
|
27
|
-
name: 'name',
|
|
28
|
-
message: 'Extension name?',
|
|
29
|
-
type: 'text',
|
|
30
|
-
initial: extension.name,
|
|
31
|
-
validate: prev => prev.length >= 3,
|
|
32
|
-
format: name => String.hyphenate(name),
|
|
33
|
-
});
|
|
34
|
-
await Tasks.run({}, [
|
|
35
|
-
{
|
|
36
|
-
title: 'Validating extension options..',
|
|
37
|
-
async task(ctx) {
|
|
38
|
-
ctx.directory = await ensureExtensionDirectoryExists(name);
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: 'Initializing extension..',
|
|
43
|
-
async task(ctx) {
|
|
44
|
-
await initThemeExtension({
|
|
45
|
-
app,
|
|
46
|
-
name,
|
|
47
|
-
type,
|
|
48
|
-
flavor,
|
|
49
|
-
directory: ctx.directory,
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
this.output.info(`Extension '${name}' successfully generated.`);
|
|
55
|
-
}
|
|
7
|
+
class GenerateExtension extends AppCommand {
|
|
8
|
+
static description = 'Generate an app extension';
|
|
9
|
+
async run() {
|
|
10
|
+
const filepath = Path.resolve(Path.cwd(), APP_CONFIG_FILENAME);
|
|
11
|
+
const app = await Filesystem.readJsonFile(filepath);
|
|
12
|
+
const { identifier } = await this.prompt({
|
|
13
|
+
name: 'identifier',
|
|
14
|
+
message: 'Extension type?',
|
|
15
|
+
type: 'select',
|
|
16
|
+
choices: extensions.map(ext => ({
|
|
17
|
+
title: ext.name,
|
|
18
|
+
value: ext.identifier,
|
|
19
|
+
description: ext.description,
|
|
20
|
+
})),
|
|
21
|
+
});
|
|
22
|
+
// TODO: prompt for extension type and flavor
|
|
23
|
+
const extension = extensions.find(ext => ext.identifier === identifier);
|
|
24
|
+
const type = extension.types[0];
|
|
25
|
+
const flavor = type.flavors[0];
|
|
26
|
+
const { name } = await this.prompt({
|
|
27
|
+
name: 'name',
|
|
28
|
+
message: 'Extension name?',
|
|
29
|
+
type: 'text',
|
|
30
|
+
initial: extension.name,
|
|
31
|
+
validate: prev => prev.length >= 3,
|
|
32
|
+
format: name => String.hyphenate(name),
|
|
33
|
+
});
|
|
34
|
+
await Tasks.run({}, [
|
|
35
|
+
{
|
|
36
|
+
title: 'Validating extension options..',
|
|
37
|
+
async task(ctx) {
|
|
38
|
+
ctx.directory = await ensureExtensionDirectoryExists(name);
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: 'Initializing extension..',
|
|
43
|
+
async task(ctx) {
|
|
44
|
+
await initThemeExtension({
|
|
45
|
+
app,
|
|
46
|
+
name,
|
|
47
|
+
type,
|
|
48
|
+
flavor,
|
|
49
|
+
directory: ctx.directory,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
this.output.info(`Extension '${name}' successfully generated.`);
|
|
55
|
+
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export { GenerateExtension as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AppCommand } from '@/util/
|
|
2
|
-
export default class Install extends AppCommand {
|
|
3
|
-
static description: string;
|
|
4
|
-
run(): Promise<void>;
|
|
5
|
-
}
|
|
1
|
+
import { AppCommand } from '@/util/app-command';
|
|
2
|
+
export default class Install extends AppCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
run(): Promise<void>;
|
|
5
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { Session, Tasks, Http, Env, System } from '@youcan/cli-kit';
|
|
2
2
|
import { load } from '../../../util/app-loader.js';
|
|
3
|
-
import { AppCommand } from '../../../util/
|
|
3
|
+
import { AppCommand } from '../../../util/app-command.js';
|
|
4
4
|
|
|
5
|
-
class Install extends AppCommand {
|
|
6
|
-
static description = 'Generate an app installation URL';
|
|
7
|
-
async run() {
|
|
8
|
-
const app = await load();
|
|
9
|
-
if (!app.config.id) {
|
|
10
|
-
this.output.error('Please run the `dev` command before installing your app.');
|
|
11
|
-
}
|
|
12
|
-
await Session.authenticate(this);
|
|
13
|
-
const { url } = await Tasks.run({}, [
|
|
14
|
-
{
|
|
15
|
-
title: 'Building authorization url',
|
|
16
|
-
async task(ctx) {
|
|
17
|
-
const { url } = await Http.get(`${Env.apiHostname()}/apps/${app.config.id}/authorization-url`);
|
|
18
|
-
ctx.url = url;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
]);
|
|
22
|
-
await this.output.anykey('Press any key to open the installation page in your browser');
|
|
23
|
-
System.open(url);
|
|
24
|
-
}
|
|
5
|
+
class Install extends AppCommand {
|
|
6
|
+
static description = 'Generate an app installation URL';
|
|
7
|
+
async run() {
|
|
8
|
+
const app = await load();
|
|
9
|
+
if (!app.config.id) {
|
|
10
|
+
this.output.error('Please run the `dev` command before installing your app.');
|
|
11
|
+
}
|
|
12
|
+
await Session.authenticate(this);
|
|
13
|
+
const { url } = await Tasks.run({}, [
|
|
14
|
+
{
|
|
15
|
+
title: 'Building authorization url',
|
|
16
|
+
async task(ctx) {
|
|
17
|
+
const { url } = await Http.get(`${Env.apiHostname()}/apps/${app.config.id}/authorization-url`);
|
|
18
|
+
ctx.url = url;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
await this.output.anykey('Press any key to open the installation page in your browser');
|
|
23
|
+
System.open(url);
|
|
24
|
+
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export { Install as default };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { App } from '@/types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Worker } from '@youcan/cli-kit';
|
|
2
|
+
import type { App } from '@/types';
|
|
3
|
+
import type DevCommand from '@/cli/commands/app/dev';
|
|
4
|
+
export default class AppWorker extends Worker.Abstract {
|
|
5
|
+
private command;
|
|
6
|
+
private app;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(command: DevCommand, app: App);
|
|
9
|
+
boot(): Promise<void>;
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import { Worker,
|
|
1
|
+
import { Worker, Filesystem, Path } from '@youcan/cli-kit';
|
|
2
2
|
import { APP_CONFIG_FILENAME } from '../../../../constants.js';
|
|
3
3
|
|
|
4
|
-
class AppWorker extends Worker.Abstract {
|
|
5
|
-
command;
|
|
6
|
-
app;
|
|
7
|
-
logger;
|
|
8
|
-
constructor(command, app) {
|
|
9
|
-
super();
|
|
10
|
-
this.command = command;
|
|
11
|
-
this.app = app;
|
|
12
|
-
this.logger = new Worker.Logger('
|
|
13
|
-
}
|
|
14
|
-
async boot() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.command.controller.abort();
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
4
|
+
class AppWorker extends Worker.Abstract {
|
|
5
|
+
command;
|
|
6
|
+
app;
|
|
7
|
+
logger;
|
|
8
|
+
constructor(command, app) {
|
|
9
|
+
super();
|
|
10
|
+
this.command = command;
|
|
11
|
+
this.app = app;
|
|
12
|
+
this.logger = new Worker.Logger('app', 'green');
|
|
13
|
+
}
|
|
14
|
+
async boot() { }
|
|
15
|
+
async run() {
|
|
16
|
+
await this.command.output.wait(500);
|
|
17
|
+
this.logger.write('watching for config updates...');
|
|
18
|
+
const watcher = Filesystem.watch(Path.resolve(this.app.root, APP_CONFIG_FILENAME), {
|
|
19
|
+
persistent: true,
|
|
20
|
+
ignoreInitial: true,
|
|
21
|
+
awaitWriteFinish: {
|
|
22
|
+
stabilityThreshold: 50,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
watcher.once('change', async () => {
|
|
26
|
+
await watcher.close();
|
|
27
|
+
this.logger.write('config update detected, reloading workers...');
|
|
28
|
+
this.command.controller.abort();
|
|
29
|
+
this.command.reloadWorkers();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export { AppWorker as default };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { Cli, Worker } from '@youcan/cli-kit';
|
|
2
|
-
import WebWorker from './web-worker';
|
|
3
|
-
import AppWorker from './app-worker';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import type { Cli, Services, Worker } from '@youcan/cli-kit';
|
|
2
|
+
import WebWorker from './web-worker';
|
|
3
|
+
import AppWorker from './app-worker';
|
|
4
|
+
import TunnelWorker from './tunnel-worker';
|
|
5
|
+
import type { App, Extension, Web } from '@/types';
|
|
6
|
+
import type DevCommand from '@/cli/commands/app/dev';
|
|
7
|
+
import type { AppCommand } from '@/util/app-command';
|
|
8
|
+
export interface ExtensionWorkerCtor {
|
|
9
|
+
new (command: Cli.Command, app: App, extension: Extension): Worker.Interface;
|
|
10
|
+
}
|
|
11
|
+
export declare function bootAppWorker(command: DevCommand, app: App): Promise<AppWorker>;
|
|
12
|
+
export declare function bootExtensionWorker(command: Cli.Command, app: App, extension: Extension): Promise<Worker.Interface>;
|
|
13
|
+
export declare function bootWebWorker(command: Cli.Command, app: App, web: Web, env: Record<string, string>): Promise<WebWorker>;
|
|
14
|
+
export declare function bootTunnelWorker(command: AppCommand, app: App, tunnel: Services.Cloudflared): Promise<TunnelWorker>;
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import ThemeExtensionWorker from './theme-extension-worker.js';
|
|
2
2
|
import WebWorker from './web-worker.js';
|
|
3
3
|
import AppWorker from './app-worker.js';
|
|
4
|
+
import TunnelWorker from './tunnel-worker.js';
|
|
4
5
|
|
|
5
|
-
const EXTENSION_WORKERS = {
|
|
6
|
-
theme: ThemeExtensionWorker,
|
|
7
|
-
};
|
|
8
|
-
async function bootAppWorker(command, app) {
|
|
9
|
-
const worker = new AppWorker(command, app);
|
|
10
|
-
await worker.boot();
|
|
11
|
-
return worker;
|
|
12
|
-
}
|
|
13
|
-
async function bootExtensionWorker(command, app, extension) {
|
|
14
|
-
const Ctor = EXTENSION_WORKERS[extension.config.type];
|
|
15
|
-
const worker = new Ctor(command, app, extension);
|
|
16
|
-
await worker.boot();
|
|
17
|
-
return worker;
|
|
18
|
-
}
|
|
19
|
-
async function bootWebWorker(command, app, web) {
|
|
20
|
-
const worker = new WebWorker(command, app, web);
|
|
21
|
-
await worker.boot();
|
|
22
|
-
return worker;
|
|
6
|
+
const EXTENSION_WORKERS = {
|
|
7
|
+
theme: ThemeExtensionWorker,
|
|
8
|
+
};
|
|
9
|
+
async function bootAppWorker(command, app) {
|
|
10
|
+
const worker = new AppWorker(command, app);
|
|
11
|
+
await worker.boot();
|
|
12
|
+
return worker;
|
|
13
|
+
}
|
|
14
|
+
async function bootExtensionWorker(command, app, extension) {
|
|
15
|
+
const Ctor = EXTENSION_WORKERS[extension.config.type];
|
|
16
|
+
const worker = new Ctor(command, app, extension);
|
|
17
|
+
await worker.boot();
|
|
18
|
+
return worker;
|
|
19
|
+
}
|
|
20
|
+
async function bootWebWorker(command, app, web, env) {
|
|
21
|
+
const worker = new WebWorker(command, app, web, env);
|
|
22
|
+
await worker.boot();
|
|
23
|
+
return worker;
|
|
24
|
+
}
|
|
25
|
+
async function bootTunnelWorker(command, app, tunnel) {
|
|
26
|
+
const worker = new TunnelWorker(command, app, tunnel);
|
|
27
|
+
await worker.boot();
|
|
28
|
+
return worker;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
export { bootAppWorker, bootExtensionWorker, bootWebWorker };
|
|
31
|
+
export { bootAppWorker, bootExtensionWorker, bootTunnelWorker, bootWebWorker };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Cli } from '@youcan/cli-kit';
|
|
2
|
-
import { Worker } from '@youcan/cli-kit';
|
|
3
|
-
import type { App, Extension } from '@/types';
|
|
4
|
-
export default class ThemeExtensionWorker extends Worker.Abstract {
|
|
5
|
-
private command;
|
|
6
|
-
private app;
|
|
7
|
-
private extension;
|
|
8
|
-
private logger;
|
|
9
|
-
private queue;
|
|
10
|
-
FILE_TYPES: string[];
|
|
11
|
-
constructor(command: Cli.Command, app: App, extension: Extension);
|
|
12
|
-
boot(): Promise<void>;
|
|
13
|
-
run(): Promise<void>;
|
|
14
|
-
private enqueue;
|
|
15
|
-
}
|
|
1
|
+
import type { Cli } from '@youcan/cli-kit';
|
|
2
|
+
import { Worker } from '@youcan/cli-kit';
|
|
3
|
+
import type { App, Extension } from '@/types';
|
|
4
|
+
export default class ThemeExtensionWorker extends Worker.Abstract {
|
|
5
|
+
private command;
|
|
6
|
+
private app;
|
|
7
|
+
private extension;
|
|
8
|
+
private logger;
|
|
9
|
+
private queue;
|
|
10
|
+
FILE_TYPES: string[];
|
|
11
|
+
constructor(command: Cli.Command, app: App, extension: Extension);
|
|
12
|
+
boot(): Promise<void>;
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
private enqueue;
|
|
15
|
+
}
|