@youcan/theme 2.0.6 → 2.1.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.
@@ -6,6 +6,7 @@ declare class Init extends ThemeCommand {
6
6
  };
7
7
  static flags: {
8
8
  url: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ inplace: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
10
  path: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
11
  'no-color': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
12
  verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
@@ -22,12 +22,18 @@ class Init extends ThemeCommand {
22
22
  description: 'The Git URL to clone from',
23
23
  default: 'https://github.com/youcan-shop/dusk',
24
24
  }),
25
+ inplace: Flags.boolean({
26
+ char: 'i',
27
+ default: false,
28
+ env: 'YC_FLAG_INPLACE',
29
+ description: 'Initialize the current directory as a dev theme instead of cloning',
30
+ }),
25
31
  };
26
32
  async run() {
27
33
  const { flags } = await this.parse(Init);
28
34
  const session = await Session.authenticate(this);
29
35
  const answers = await (prompt(this));
30
- const dest = Path.join(flags.path, answers.theme_name);
36
+ const dest = Path.join(flags.path, flags.inplace ? '' : answers.theme_name);
31
37
  await Tasks.run({
32
38
  payload: answers,
33
39
  theme_id: null,
@@ -35,6 +41,7 @@ class Init extends ThemeCommand {
35
41
  }, [
36
42
  {
37
43
  title: `Cloning ${flags.url} into ${dest}...`,
44
+ skip: () => flags.inplace,
38
45
  task: async () => {
39
46
  await Git.clone({ url: flags.url, destination: dest });
40
47
  },
@@ -42,12 +49,18 @@ class Init extends ThemeCommand {
42
49
  {
43
50
  title: 'Initializing development theme...',
44
51
  task: async (ctx) => {
45
- const path = await Filesystem.archived(Path.resolve(Path.cwd(), answers.theme_name), answers.theme_name);
52
+ const path = await Filesystem.archived(dest, answers.theme_name);
53
+ const configPath = Path.join(Path.cwd(), THEME_CONFIG_FILENAME);
54
+ if (flags.inplace && await Filesystem.exists(configPath)) {
55
+ throw new Error(`
56
+ This directory is already linked to a remote theme,
57
+ please delete youcan.app.json if you wish to create a new one
58
+ `);
59
+ }
46
60
  Object.assign(ctx.payload, { archive: await Form.file(path) });
47
- const form = Form.convert(ctx.payload);
48
61
  const res = await Http.post(`${Env.apiHostname()}/themes/init`, {
49
62
  headers: { Authorization: `Bearer ${session.access_token}` },
50
- body: form,
63
+ body: Form.convert(ctx.payload),
51
64
  });
52
65
  ctx.theme_id = res.id;
53
66
  await Filesystem.unlink(path);
@@ -56,7 +69,7 @@ class Init extends ThemeCommand {
56
69
  {
57
70
  title: 'Cleaning up...',
58
71
  task: async (ctx) => {
59
- await Filesystem.writeJsonFile(Path.join(Path.cwd(), ctx.payload.theme_name, THEME_CONFIG_FILENAME), { theme_id: ctx.theme_id });
72
+ await Filesystem.writeJsonFile(Path.join(dest, THEME_CONFIG_FILENAME), { theme_id: ctx.theme_id });
60
73
  ctx.cmd.output.info(`\nDevelopment theme '${ctx.theme_id}' initiated!`);
61
74
  },
62
75
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@youcan/theme",
3
3
  "type": "module",
4
- "version": "2.0.6",
4
+ "version": "2.1.1",
5
5
  "description": "OCLIF plugin for building themes",
6
6
  "author": "YouCan <contact@youcan.shop> (https://youcan.shop)",
7
7
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  "@oclif/core": "^2.15.0",
19
19
  "debounce": "^2.0.0",
20
20
  "socket.io": "^4.7.2",
21
- "@youcan/cli-kit": "2.0.6"
21
+ "@youcan/cli-kit": "2.1.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@oclif/plugin-legacy": "^1.3.0",