@pubinfo/cli 2.0.0-beta.3 → 2.0.0-beta.31

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 { build } from '@pubinfo/vite';
1
+ import { build, mergeConfig } from '@pubinfo/vite';
2
2
  import { defineCommand, runMain } from 'citty';
3
3
  import { loadConfig } from 'unconfig';
4
4
  import command$1 from './generate.mjs';
@@ -13,18 +13,38 @@ const command = defineCommand({
13
13
  name: "build",
14
14
  description: "Build the application for production"
15
15
  },
16
- async run() {
16
+ args: {
17
+ watch: {
18
+ type: "boolean",
19
+ alias: "w"
20
+ },
21
+ mode: {
22
+ type: "string",
23
+ alias: "m"
24
+ },
25
+ config: {
26
+ type: "string",
27
+ alias: "c"
28
+ }
29
+ },
30
+ async run({ args }) {
17
31
  await runMain(command$1);
18
32
  const { config } = await loadConfig({
19
33
  sources: [
20
- { files: "pubinfo.config" }
34
+ { files: args.config || "pubinfo.config" }
21
35
  ],
22
36
  merge: false
23
37
  });
24
- const inlineConfig = typeof config.vite === "function" ? await config.vite({ mode: "production", command: "build" }) : config.vite;
25
- await build({
26
- ...inlineConfig
27
- });
38
+ const inlineConfig = typeof config.vite === "function" ? config.vite({ mode: "production", command: "build" }) : config.vite;
39
+ await build(mergeConfig(
40
+ inlineConfig ?? {},
41
+ {
42
+ mode: args.mode,
43
+ build: {
44
+ watch: args.watch ? {} : null
45
+ }
46
+ }
47
+ ));
28
48
  }
29
49
  });
30
50
 
@@ -1,4 +1,4 @@
1
- import { createServer } from '@pubinfo/vite';
1
+ import { createServer, mergeConfig } from '@pubinfo/vite';
2
2
  import { defineCommand, runMain } from 'citty';
3
3
  import { loadConfig } from 'unconfig';
4
4
  import command$1 from './generate.mjs';
@@ -13,20 +13,42 @@ const command = defineCommand({
13
13
  name: "dev",
14
14
  description: "Run Pubinfo development server"
15
15
  },
16
- async run() {
16
+ args: {
17
+ host: {
18
+ type: "string"
19
+ },
20
+ port: {
21
+ type: "string"
22
+ },
23
+ mode: {
24
+ type: "string",
25
+ alias: "m"
26
+ },
27
+ config: {
28
+ type: "string",
29
+ alias: "c"
30
+ }
31
+ },
32
+ async run({ args }) {
17
33
  await runMain(command$1);
18
34
  const { config } = await loadConfig({
19
35
  sources: [
20
- { files: "pubinfo.config" }
36
+ { files: args.config || "pubinfo.config" }
21
37
  ],
22
38
  merge: false
23
39
  });
24
- const inlineConfig = typeof config.vite === "function" ? await config.vite({ mode: "development", command: "serve" }) : config.vite;
25
- const server = await createServer({
26
- ...inlineConfig,
27
- mode: "development",
28
- configFile: false
29
- });
40
+ const inlineConfig = typeof config.vite === "function" ? config.vite({ mode: "development", command: "serve" }) : config.vite;
41
+ const server = await createServer(mergeConfig(
42
+ inlineConfig ?? {},
43
+ {
44
+ server: {
45
+ host: args.host,
46
+ port: args.port ? Number(args.port) : void 0
47
+ },
48
+ mode: args.mode,
49
+ configFile: false
50
+ }
51
+ ));
30
52
  await server.listen();
31
53
  server.printUrls();
32
54
  server.bindCLIShortcuts({ print: true });
@@ -7,7 +7,9 @@ import { join } from 'node:path';
7
7
 
8
8
  function writeTsconfig(filePath) {
9
9
  const require = createRequire(import.meta.url);
10
- const resolveDeps = (name, path) => join(require.resolve(name), path);
10
+ const resolveDeps = (name, path) => {
11
+ return join(require.resolve(name), path).replace(/\\/g, "/");
12
+ };
11
13
  writeFileSync(filePath, `/* eslint-disable */
12
14
  /* prettier-ignore */
13
15
  // Generated by pubinfo
@@ -0,0 +1,46 @@
1
+ import { preview, mergeConfig } from '@pubinfo/vite';
2
+ import { defineCommand } from 'citty';
3
+ import { loadConfig } from 'unconfig';
4
+
5
+ const command = defineCommand({
6
+ meta: {
7
+ name: "preview",
8
+ description: "Preview the application"
9
+ },
10
+ args: {
11
+ host: {
12
+ type: "string"
13
+ },
14
+ port: {
15
+ type: "string"
16
+ },
17
+ mode: {
18
+ type: "string",
19
+ alias: "m"
20
+ }
21
+ },
22
+ async run({ args }) {
23
+ const { config } = await loadConfig({
24
+ sources: [
25
+ { files: "pubinfo.config" }
26
+ ],
27
+ merge: false
28
+ });
29
+ const inlineConfig = typeof config.vite === "function" ? config.vite({ mode: "production", command: "serve" }) : config.vite;
30
+ const previewServer = await preview(mergeConfig(
31
+ inlineConfig ?? {},
32
+ {
33
+ preview: {
34
+ host: args.host,
35
+ port: args.port ? Number(args.port) : void 0
36
+ },
37
+ mode: args.mode,
38
+ configFile: false
39
+ }
40
+ ));
41
+ previewServer.printUrls();
42
+ previewServer.bindCLIShortcuts({ print: true });
43
+ }
44
+ });
45
+
46
+ export { command as default };
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { defineCommand, runMain as runMain$1 } from 'citty';
2
2
  import { fileURLToPath } from 'node:url';
3
3
 
4
4
  const name = "@pubinfo/cli";
5
- const version = "2.0.0-beta.3";
5
+ const version = "2.0.0-beta.31";
6
6
  const description = "CLI for Pubinfo";
7
7
  const cliPkg = {
8
8
  name: name,
@@ -13,6 +13,7 @@ const _rDefault = (r) => r.default || r;
13
13
  const commands = {
14
14
  dev: () => import('./chunks/dev.mjs').then(_rDefault),
15
15
  build: () => import('./chunks/build.mjs').then(_rDefault),
16
+ preview: () => import('./chunks/preview.mjs').then(_rDefault),
16
17
  generate: () => import('./chunks/generate.mjs').then(_rDefault)
17
18
  };
18
19
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/cli",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.3",
4
+ "version": "2.0.0-beta.31",
5
5
  "description": "CLI for Pubinfo",
6
6
  "exports": {
7
7
  ".": "./bin/pubinfo.mjs"
@@ -15,18 +15,17 @@
15
15
  "dist"
16
16
  ],
17
17
  "peerDependencies": {
18
- "@pubinfo/vite": "2.0.0-beta.3"
18
+ "@pubinfo/vite": "2.0.0-beta.31"
19
19
  },
20
20
  "dependencies": {
21
21
  "citty": "^0.1.6",
22
22
  "pathe": "^1.1.2",
23
- "unconfig": "^7.3.0"
23
+ "unconfig": "^7.3.2"
24
24
  },
25
25
  "devDependencies": {
26
- "@types/node": "^22.13.9",
26
+ "@types/node": "^22.15.27",
27
27
  "unbuild": "^3.5.0",
28
- "unplugin-purge-polyfills": "^0.0.7",
29
- "@pubinfo/vite": "2.0.0-beta.3"
28
+ "@pubinfo/vite": "2.0.0-beta.31"
30
29
  },
31
30
  "scripts": {
32
31
  "stub": "unbuild --stub",