@youcan/cli 1.0.3 → 1.0.5

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.
@@ -108,6 +108,7 @@ function command(cli) {
108
108
  description: 'starts a dev server and watches over the current directory',
109
109
  options: [
110
110
  { name: '-p, --preview', description: 'opens a preview window' },
111
+ { name: '-d, --disable-hardware-acceleration', description: 'disable hardware acceleration' },
111
112
  ],
112
113
  action: async (options) => {
113
114
  let socket;
@@ -125,7 +126,7 @@ function command(cli) {
125
126
  if (options.preview) {
126
127
  socket = connectPreviewServer();
127
128
  socket.emit('theme:dev', { themeId });
128
- previewTheme(`https://${domain}/themes/${themeId}/preview`);
129
+ previewTheme(`https://${domain}/themes/${themeId}/preview`, options);
129
130
  }
130
131
  stdout.info(`Watching for changes in ${kleur.bold().white(cwd())}...`);
131
132
  chokidar
@@ -3,6 +3,7 @@ import stdout from '../../../utils/system/stdout.js';
3
3
  import { getCurrentThemeId, getCurrentDate, LoadingSpinner } from '../../../utils/common.js';
4
4
  import messages from '../../../config/messages.js';
5
5
  import { zipDirectory } from '../../../utils/system/zipFolder.js';
6
+ import config from '../../../config/index.js';
6
7
 
7
8
  function command(cli) {
8
9
  return {
@@ -18,7 +19,7 @@ function command(cli) {
18
19
  const loading = new LoadingSpinner('📦 Packaging your theme');
19
20
  loading.start();
20
21
  const exportFolder = `theme_${getCurrentDate()}`;
21
- await zipDirectory(cwd(), exportFolder);
22
+ await zipDirectory(cwd(), exportFolder, config.THEME_FILE_TYPES);
22
23
  loading.stop();
23
24
  return stdout.info(`your theme was successfully packaged to ${exportFolder}`);
24
25
  },
@@ -4,12 +4,15 @@ import puppeteer from 'puppeteer';
4
4
  import stdout from '../../utils/system/stdout.js';
5
5
  import config from '../../config/index.js';
6
6
 
7
- async function openPreviewPage(url) {
8
- const browser = await puppeteer.launch({
7
+ async function openPreviewPage(url, disableHardwareAcceleration) {
8
+ const options = {
9
9
  headless: false,
10
10
  defaultViewport: null,
11
11
  userDataDir: '/tmp/youcan_puppeteer',
12
- });
12
+ };
13
+ if (disableHardwareAcceleration)
14
+ options.args = ['--disable-gpu'];
15
+ const browser = await puppeteer.launch(options);
13
16
  browser.on('disconnected', () => {
14
17
  stdout.info('Browser closed');
15
18
  return process.exit(0);
@@ -18,10 +21,10 @@ async function openPreviewPage(url) {
18
21
  await page.goto(url);
19
22
  return page;
20
23
  }
21
- async function previewTheme(url) {
24
+ async function previewTheme(url, options) {
22
25
  const httpServer = createServer();
23
26
  const io = new Server(httpServer);
24
- const previewPage = await openPreviewPage(url);
27
+ const previewPage = await openPreviewPage(url, options.disableHardwareAcceleration);
25
28
  io.on('connection', (socket) => {
26
29
  socket.on('theme:update', async () => {
27
30
  await previewPage.reload({ waitUntil: 'domcontentloaded' });
@@ -1 +1 @@
1
- export default function previewTheme(url: string): Promise<void>;
1
+ export default function previewTheme(url: string, options: Record<string, string>): Promise<void>;
@@ -2,4 +2,4 @@
2
2
  * Zip folder and save it to a given path and return zip folder path
3
3
  */
4
4
  export declare function zipFolder(folderPath: string, folderName: string): Promise<string>;
5
- export declare function zipDirectory(dirPath: string, folderName: string): Promise<unknown>;
5
+ export declare function zipDirectory(dirPath: string, folderName: string, only?: string[]): Promise<unknown>;
@@ -29,8 +29,8 @@ async function zipFolder(folderPath, folderName) {
29
29
  }
30
30
  });
31
31
  }
32
- async function zipDirectory(dirPath, folderName) {
33
- const ls = lsDir(dirPath);
32
+ async function zipDirectory(dirPath, folderName, only) {
33
+ const ls = lsDir(dirPath).filter(folder => only === null || only === void 0 ? void 0 : only.includes(folder));
34
34
  return new Promise((resolve, reject) => {
35
35
  try {
36
36
  const zip = path.resolve(dirPath, `${folderName}.zip`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@youcan/cli",
3
3
  "type": "module",
4
- "version": "1.0.3",
4
+ "version": "1.0.5",
5
5
  "description": "YouCan CLI for developers.",
6
6
  "author": "YouCan <contact@youcan.shop> (https://youcan.shop)",
7
7
  "keywords": [],
@@ -20,15 +20,6 @@
20
20
  "bin",
21
21
  "dist"
22
22
  ],
23
- "scripts": {
24
- "build": "tsc --noEmit && rollup --config rollup.config.js",
25
- "dev": "rollup --config rollup.config.js --watch",
26
- "lint": "eslint .",
27
- "release": "bumpp && pnpm publish",
28
- "typecheck": "tsc --noEmit",
29
- "test": "vitest",
30
- "check": "pnpm typecheck && pnpm lint && pnpm run test"
31
- },
32
23
  "dependencies": {
33
24
  "archiver": "^5.3.1",
34
25
  "cac": "^6.7.14",
@@ -66,5 +57,14 @@
66
57
  "typescript": "^4.8.4",
67
58
  "vite": "^3.2.4",
68
59
  "vitest": "^0.24.5"
60
+ },
61
+ "scripts": {
62
+ "build": "tsc --noEmit && rollup --config rollup.config.js",
63
+ "dev": "rollup --config rollup.config.js --watch",
64
+ "lint": "eslint .",
65
+ "release": "bumpp && pnpm publish",
66
+ "typecheck": "tsc --noEmit",
67
+ "test": "vitest",
68
+ "check": "pnpm typecheck && pnpm lint && pnpm run test"
69
69
  }
70
- }
70
+ }