@youcan/theme 1.2.0-beta.8 → 1.2.0-beta.9
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/theme/delete.js +2 -2
- package/dist/cli/commands/theme/init.js +1 -1
- package/dist/cli/commands/theme/list.d.ts +4 -0
- package/dist/cli/commands/theme/list.js +31 -0
- package/dist/cli/commands/theme/pack.d.ts +5 -0
- package/dist/cli/commands/theme/pack.js +45 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ class Delete extends ThemeCommand {
|
|
|
8
8
|
if (!themes.length) {
|
|
9
9
|
return this.output.info('You have no remote dev themes');
|
|
10
10
|
}
|
|
11
|
-
const choices = themes.map(t => ({ title: t.name
|
|
11
|
+
const choices = themes.map(t => ({ title: `${t.name} (${t.id})`, value: t.id }));
|
|
12
12
|
const { identifiers } = await this.prompt({
|
|
13
13
|
choices,
|
|
14
14
|
type: 'multiselect',
|
|
@@ -18,7 +18,7 @@ class Delete extends ThemeCommand {
|
|
|
18
18
|
const tasks = identifiers.map((id) => {
|
|
19
19
|
const theme = themes.find(t => t.id === id);
|
|
20
20
|
return {
|
|
21
|
-
title: `Deleting '${theme.name}'...`,
|
|
21
|
+
title: `Deleting '${theme.name} (${theme.id})'...`,
|
|
22
22
|
async task() {
|
|
23
23
|
await Http.post(`${Env.apiHostname()}/themes/${theme.id}/delete`);
|
|
24
24
|
},
|
|
@@ -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,31 @@
|
|
|
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
|
+
async run() {
|
|
12
|
+
await Session.authenticate(this);
|
|
13
|
+
const { dev: themes } = await Http.get(`${Env.apiHostname()}/themes`);
|
|
14
|
+
if (!themes.length) {
|
|
15
|
+
return this.output.info('You have no remote dev themes');
|
|
16
|
+
}
|
|
17
|
+
this.output.table(themes.map(t => ({
|
|
18
|
+
id: t.id,
|
|
19
|
+
name: t.name,
|
|
20
|
+
version: t.version,
|
|
21
|
+
size: formatter.format(t.size),
|
|
22
|
+
})), {
|
|
23
|
+
id: { header: 'Identifier' },
|
|
24
|
+
name: { header: 'Name' },
|
|
25
|
+
version: { header: 'Version' },
|
|
26
|
+
size: { header: 'Size' },
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { List as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
async run() {
|
|
29
|
+
await Session.authenticate(this);
|
|
30
|
+
const theme = await load();
|
|
31
|
+
const context = await Tasks.run({}, [
|
|
32
|
+
{
|
|
33
|
+
title: 'Packing your theme...',
|
|
34
|
+
async task(ctx) {
|
|
35
|
+
const name = `${Path.basename(theme.root)}-${date()}`;
|
|
36
|
+
ctx.path = await Filesystem.archived(theme.root, name, `{${FILE_TYPES.join(',')}}/*`);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
const { size } = await Filesystem.stat(context.path);
|
|
41
|
+
this.output.info(`Theme successfully packed into ${Path.basename(context.path)} (${formatter.format(size)})`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { date, Pack as default };
|
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.
|
|
4
|
+
"version": "1.2.0-beta.9",
|
|
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.
|
|
21
|
+
"@youcan/cli-kit": "1.2.0-beta.9"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@oclif/plugin-legacy": "^1.3.0",
|