@youcan/theme 1.2.0-beta.8 → 2.0.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.
@@ -1,4 +1,5 @@
1
1
  import { ThemeCommand } from '@/util/theme-command';
2
2
  export default class Delete extends ThemeCommand {
3
+ static description: string;
3
4
  run(): Promise<void>;
4
5
  }
@@ -2,13 +2,14 @@ import { Session, Http, Env, Tasks } from '@youcan/cli-kit';
2
2
  import { ThemeCommand } from '../../../util/theme-command.js';
3
3
 
4
4
  class Delete extends ThemeCommand {
5
+ static description = 'Select remote development themes to delete';
5
6
  async run() {
6
7
  await Session.authenticate(this);
7
8
  const { dev: themes } = await Http.get(`${Env.apiHostname()}/themes`);
8
9
  if (!themes.length) {
9
10
  return this.output.info('You have no remote dev themes');
10
11
  }
11
- const choices = themes.map(t => ({ title: t.name, value: t.id }));
12
+ const choices = themes.map(t => ({ title: `${t.name} (${t.id})`, value: t.id }));
12
13
  const { identifiers } = await this.prompt({
13
14
  choices,
14
15
  type: 'multiselect',
@@ -18,7 +19,7 @@ class Delete extends ThemeCommand {
18
19
  const tasks = identifiers.map((id) => {
19
20
  const theme = themes.find(t => t.id === id);
20
21
  return {
21
- title: `Deleting '${theme.name}'...`,
22
+ title: `Deleting '${theme.name} (${theme.id})'...`,
22
23
  async task() {
23
24
  await Http.post(`${Env.apiHostname()}/themes/${theme.id}/delete`);
24
25
  },
@@ -1,4 +1,5 @@
1
1
  import { ThemeCommand } from '@/util/theme-command';
2
2
  export default class Dev extends ThemeCommand {
3
+ static description: string;
3
4
  run(): Promise<void>;
4
5
  }
@@ -4,6 +4,7 @@ import { load } from '../../../util/theme-loader.js';
4
4
  import ThemeWorker from '../../services/dev/worker.js';
5
5
 
6
6
  class Dev extends ThemeCommand {
7
+ static description = 'Start a theme development server and preview your changes';
7
8
  async run() {
8
9
  const theme = await load();
9
10
  await Session.authenticate(this);
@@ -5,7 +5,7 @@ import { THEME_FLAGS } from '../../../flags.js';
5
5
  import { THEME_CONFIG_FILENAME } from '../../../constants.js';
6
6
 
7
7
  class Init extends ThemeCommand {
8
- static description = 'Clones a theme template Git repo.';
8
+ static description = 'Clones a theme template git repo';
9
9
  static args = {
10
10
  name: Args.string({
11
11
  name: 'name',
@@ -20,7 +20,7 @@ class Init extends ThemeCommand {
20
20
  char: 'u',
21
21
  env: 'YC_FLAG_CLONE_URL',
22
22
  description: 'The Git URL to clone from',
23
- default: 'https://github.com/youcan-shop/light-theme',
23
+ default: 'https://github.com/youcan-shop/dusk',
24
24
  }),
25
25
  };
26
26
  async run() {
@@ -42,7 +42,7 @@ class Init extends ThemeCommand {
42
42
  {
43
43
  title: 'Initializing development theme...',
44
44
  task: async (ctx) => {
45
- const path = await Filesystem.archived(Path.cwd(), answers.theme_name);
45
+ const path = await Filesystem.archived(Path.resolve(Path.cwd(), answers.theme_name), answers.theme_name);
46
46
  Object.assign(ctx.payload, { archive: await Form.file(path) });
47
47
  const form = Form.convert(ctx.payload);
48
48
  const res = await Http.post(`${Env.apiHostname()}/themes/init`, {
@@ -0,0 +1,5 @@
1
+ import { ThemeCommand } from '@/util/theme-command';
2
+ export default class List extends ThemeCommand {
3
+ static description: string;
4
+ run(): Promise<void>;
5
+ }
@@ -0,0 +1,32 @@
1
+ import { Session, Http, Env } from '@youcan/cli-kit';
2
+ import { ThemeCommand } from '../../../util/theme-command.js';
3
+
4
+ const formatter = Intl.NumberFormat('en', {
5
+ notation: 'compact',
6
+ style: 'unit',
7
+ unit: 'byte',
8
+ unitDisplay: 'narrow',
9
+ });
10
+ class List extends ThemeCommand {
11
+ static description = 'List remote development themes';
12
+ async run() {
13
+ await Session.authenticate(this);
14
+ const { dev: themes } = await Http.get(`${Env.apiHostname()}/themes`);
15
+ if (!themes.length) {
16
+ return this.output.info('You have no remote dev themes');
17
+ }
18
+ this.output.table(themes.map(t => ({
19
+ id: t.id,
20
+ name: t.name,
21
+ version: t.version,
22
+ size: formatter.format(t.size),
23
+ })), {
24
+ id: { header: 'Identifier' },
25
+ name: { header: 'Name' },
26
+ version: { header: 'Version' },
27
+ size: { header: 'Size' },
28
+ });
29
+ }
30
+ }
31
+
32
+ export { List as default };
@@ -0,0 +1,6 @@
1
+ import { ThemeCommand } from '@/util/theme-command';
2
+ export declare function date(): string;
3
+ export default class Pack extends ThemeCommand {
4
+ static description: string;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,46 @@
1
+ import { Session, Tasks, Path, Filesystem } from '@youcan/cli-kit';
2
+ import { ThemeCommand } from '../../../util/theme-command.js';
3
+ import { load } from '../../../util/theme-loader.js';
4
+
5
+ const formatter = Intl.NumberFormat('en', {
6
+ notation: 'compact',
7
+ style: 'unit',
8
+ unit: 'byte',
9
+ unitDisplay: 'narrow',
10
+ });
11
+ const FILE_TYPES = [
12
+ 'layouts',
13
+ 'sections',
14
+ 'locales',
15
+ 'assets',
16
+ 'snippets',
17
+ 'config',
18
+ 'templates',
19
+ ];
20
+ function date() {
21
+ const date = new Date();
22
+ const day = date.getDate();
23
+ const month = date.getMonth() + 1;
24
+ const year = date.getFullYear();
25
+ return `${day}-${month}-${year}`;
26
+ }
27
+ class Pack extends ThemeCommand {
28
+ static description = 'Pack your theme into an archive to upload or share';
29
+ async run() {
30
+ await Session.authenticate(this);
31
+ const theme = await load();
32
+ const context = await Tasks.run({}, [
33
+ {
34
+ title: 'Packing your theme...',
35
+ async task(ctx) {
36
+ const name = `${Path.basename(theme.root)}-${date()}`;
37
+ ctx.path = await Filesystem.archived(theme.root, name, `{${FILE_TYPES.join(',')}}/*`);
38
+ },
39
+ },
40
+ ]);
41
+ const { size } = await Filesystem.stat(context.path);
42
+ this.output.info(`Theme successfully packed into ${Path.basename(context.path)} (${formatter.format(size)})`);
43
+ }
44
+ }
45
+
46
+ export { date, Pack as default };
@@ -129,7 +129,9 @@ class ThemeWorker extends Worker.Abstract {
129
129
  }, 100)();
130
130
  }
131
131
  catch (err) {
132
- this.logger.write(`[error] - ${Path.join(type, name)}`);
132
+ if (err instanceof Error) {
133
+ this.logger.write(`[error] - ${Path.join(type, name)}\n${err.message}`);
134
+ }
133
135
  }
134
136
  });
135
137
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@youcan/theme",
3
3
  "type": "module",
4
- "version": "1.2.0-beta.8",
4
+ "version": "2.0.0",
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": "1.2.0-beta.8"
21
+ "@youcan/cli-kit": "2.0.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@oclif/plugin-legacy": "^1.3.0",