@youcan/app 1.1.0-beta.2 → 1.1.0-beta.3

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.
@@ -1,4 +1,4 @@
1
- import { Session, Tasks, Http, Env, Filesystem, Path } from '@youcan/cli-kit';
1
+ import { Session, Tasks, Env, Http, Filesystem, Path } from '@youcan/cli-kit';
2
2
  import { AppCommand } from '../../../util/theme-command.js';
3
3
  import { load } from '../../../util/app-loader.js';
4
4
  import { APP_CONFIG_FILENAME } from '../../../constants.js';
@@ -10,19 +10,24 @@ class Dev extends AppCommand {
10
10
  const session = await Session.authenticate(this);
11
11
  await Tasks.run({ cmd: this }, [
12
12
  {
13
- title: 'Creating draft app..',
14
- skip() {
15
- return app.config.id != null;
16
- },
13
+ title: 'Syncing app configuration..',
17
14
  async task() {
18
- const res = await Http.post(`${Env.apiHostname()}/apps/draft/create`, {
15
+ const endpoint = app.config.id == null
16
+ ? `${Env.apiHostname()}/apps/draft/create`
17
+ : `${Env.apiHostname()}/apps/draft/${app.config.id}/update`;
18
+ const res = await Http.post(endpoint, {
19
19
  headers: { Authorization: `Bearer ${session.access_token}` },
20
- body: JSON.stringify({ name: app.config.name }),
20
+ body: JSON.stringify({
21
+ name: app.config.name,
22
+ app_url: app.config.app_url,
23
+ redirect_urls: app.config.redirect_urls,
24
+ }),
21
25
  });
22
26
  app.config = {
23
27
  name: res.name,
24
28
  id: res.id,
25
- url: res.url,
29
+ app_url: res.app_url,
30
+ redirect_urls: res.redirect_urls,
26
31
  oauth: {
27
32
  scopes: res.scopes,
28
33
  client_id: res.client_id,
@@ -0,0 +1,4 @@
1
+ import { AppCommand } from '@/util/theme-command';
2
+ export default class Install extends AppCommand {
3
+ run(): Promise<void>;
4
+ }
@@ -0,0 +1,26 @@
1
+ import { Session, Tasks, Http, Env, System } from '@youcan/cli-kit';
2
+ import { load } from '../../../util/app-loader.js';
3
+ import { AppCommand } from '../../../util/theme-command.js';
4
+
5
+ class Install extends AppCommand {
6
+ async run() {
7
+ const app = await load();
8
+ if (!app.config.id) {
9
+ this.output.error('Please run the `dev` command before installing your app.');
10
+ }
11
+ await Session.authenticate(this);
12
+ const { url } = await Tasks.run({}, [
13
+ {
14
+ title: 'Building authorization url',
15
+ async task(ctx) {
16
+ const { url } = await Http.get(`${Env.apiHostname()}/apps/draft/${app.config.id}/authorization-url`);
17
+ ctx.url = url;
18
+ },
19
+ },
20
+ ]);
21
+ await this.output.anykey('Press any key to open the installation page in your browser');
22
+ System.open(url);
23
+ }
24
+ }
25
+
26
+ export { Install as default };
package/dist/types.d.ts CHANGED
@@ -12,7 +12,8 @@ export interface ExtensionWorker {
12
12
  }
13
13
  export type AppConfig = {
14
14
  id: string;
15
- url: string;
15
+ app_url: string;
16
+ redirect_urls: string[];
16
17
  oauth: {
17
18
  client_id: string;
18
19
  scopes: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@youcan/app",
3
3
  "type": "module",
4
- "version": "1.1.0-beta.2",
4
+ "version": "1.1.0-beta.3",
5
5
  "description": "OCLIF plugin for building apps",
6
6
  "author": "YouCan <contact@youcan.shop> (https://youcan.shop)",
7
7
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "dependencies": {
18
18
  "@oclif/core": "^2.15.0",
19
- "@youcan/cli-kit": "1.1.0-beta.2"
19
+ "@youcan/cli-kit": "1.1.0-beta.3"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@oclif/plugin-legacy": "^1.3.0",