@pubinfo/cli 2.0.0-beta.2 → 2.0.0-beta.20

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,7 +13,17 @@ 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
+ },
26
+ async run({ args }) {
17
27
  await runMain(command$1);
18
28
  const { config } = await loadConfig({
19
29
  sources: [
@@ -21,10 +31,16 @@ const command = defineCommand({
21
31
  ],
22
32
  merge: false
23
33
  });
24
- const inlineConfig = typeof config.vite === "function" ? await config.vite({ mode: "production", command: "build" }) : config.vite;
25
- await build({
26
- ...inlineConfig
27
- });
34
+ const inlineConfig = typeof config.vite === "function" ? config.vite({ mode: "production", command: "build" }) : config.vite;
35
+ await build(mergeConfig(
36
+ inlineConfig ?? {},
37
+ {
38
+ mode: args.mode,
39
+ build: {
40
+ watch: args.watch ? {} : null
41
+ }
42
+ }
43
+ ));
28
44
  }
29
45
  });
30
46
 
@@ -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,7 +13,19 @@ 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
+ },
28
+ async run({ args }) {
17
29
  await runMain(command$1);
18
30
  const { config } = await loadConfig({
19
31
  sources: [
@@ -21,12 +33,18 @@ const command = defineCommand({
21
33
  ],
22
34
  merge: false
23
35
  });
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
- });
36
+ const inlineConfig = typeof config.vite === "function" ? config.vite({ mode: "development", command: "serve" }) : config.vite;
37
+ const server = await createServer(mergeConfig(
38
+ inlineConfig ?? {},
39
+ {
40
+ server: {
41
+ host: args.host,
42
+ port: args.port ? Number(args.port) : void 0
43
+ },
44
+ mode: args.mode,
45
+ configFile: false
46
+ }
47
+ ));
30
48
  await server.listen();
31
49
  server.printUrls();
32
50
  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.2";
5
+ const version = "2.0.0-beta.20";
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.2",
4
+ "version": "2.0.0-beta.20",
5
5
  "description": "CLI for Pubinfo",
6
6
  "exports": {
7
7
  ".": "./bin/pubinfo.mjs"
@@ -15,7 +15,7 @@
15
15
  "dist"
16
16
  ],
17
17
  "peerDependencies": {
18
- "@pubinfo/vite": "2.0.0-beta.2"
18
+ "@pubinfo/vite": "2.0.0-beta.20"
19
19
  },
20
20
  "dependencies": {
21
21
  "citty": "^0.1.6",
@@ -25,8 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.13.9",
27
27
  "unbuild": "^3.5.0",
28
- "unplugin-purge-polyfills": "^0.0.7",
29
- "@pubinfo/vite": "2.0.0-beta.2"
28
+ "@pubinfo/vite": "2.0.0-beta.20"
30
29
  },
31
30
  "scripts": {
32
31
  "stub": "unbuild --stub",