virmator 11.0.0 → 11.1.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,7 +1,14 @@
1
+ import {resolve} from 'path';
1
2
  import {defineConfig} from 'virmator/dist/compiled-base-configs/base-vite';
2
3
 
3
- export default defineConfig({forGitHubPages: true}, (baseConfig) => {
4
- return {
5
- ...baseConfig,
6
- };
7
- });
4
+ export default defineConfig(
5
+ {
6
+ forGitHubPages: true,
7
+ packageDirPath: resolve(__dirname, '..'),
8
+ },
9
+ (baseConfig) => {
10
+ return {
11
+ ...baseConfig,
12
+ };
13
+ },
14
+ );
@@ -1,14 +1,27 @@
1
1
  import { UserConfig, UserConfigExport } from 'vite';
2
2
  export declare const basePlugins: readonly [import("vite").PluginOption, import("vite").Plugin];
3
- export declare const currentDir: string;
4
- export declare const srcDir: string;
5
- export declare const staticDir: string;
6
- export declare const outDir: string;
7
- export declare function findGitRepoRoot(dir?: string): string;
3
+ export declare function findGitRepoRoot(dir: string): string;
8
4
  export type BaseConfigOptions = {
9
5
  /** If your prod deploy is going to be GitHub pages, set this to true. */
10
6
  forGitHubPages: boolean;
7
+ /**
8
+ * Path to the package directory that owns this vite config. Should most likely be left empty or
9
+ * set to resolve(__dirname, '..').
10
+ */
11
+ packageDirPath?: string;
12
+ /** Disables printing of server directory paths. */
13
+ disableStartupLogs?: boolean;
11
14
  };
12
- export declare function createBaseConfig({ forGitHubPages }: BaseConfigOptions): UserConfig;
13
- export declare function combineConfigs(baseConfigOptions: BaseConfigOptions, overrideCallback: ((baseConfig: UserConfig) => UserConfig | Promise<UserConfig>) | undefined): Promise<UserConfig>;
14
- export declare function defineConfig(baseConfigOptions: BaseConfigOptions, overrideCallback: ((baseConfig: UserConfig) => UserConfig | Promise<UserConfig>) | undefined): UserConfigExport;
15
+ export type ConfigPaths = {
16
+ srcDir: string;
17
+ staticDir: string;
18
+ outDir: string;
19
+ cwd: string;
20
+ };
21
+ export type OverrideCallback = (baseConfig: Readonly<UserConfig>, basePaths: Readonly<ConfigPaths>) => UserConfig | Promise<UserConfig>;
22
+ export declare function createBaseConfig({ forGitHubPages, packageDirPath }: BaseConfigOptions): {
23
+ baseConfig: UserConfig;
24
+ basePaths: ConfigPaths;
25
+ };
26
+ export declare function combineConfigs(baseConfigOptions: BaseConfigOptions, overrideCallback: OverrideCallback | undefined): Promise<UserConfig>;
27
+ export declare function defineConfig(baseConfigOptions: BaseConfigOptions, overrideCallback: OverrideCallback | undefined): UserConfigExport;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.defineConfig = exports.combineConfigs = exports.createBaseConfig = exports.findGitRepoRoot = exports.outDir = exports.staticDir = exports.srcDir = exports.currentDir = exports.basePlugins = void 0;
6
+ exports.defineConfig = exports.combineConfigs = exports.createBaseConfig = exports.findGitRepoRoot = exports.basePlugins = void 0;
7
7
  const node_js_1 = require("@augment-vir/node-js");
8
8
  const fs_1 = require("fs");
9
9
  const path_1 = require("path");
@@ -13,11 +13,7 @@ exports.basePlugins = [
13
13
  (0, vite_always_reload_plugin_1.alwaysReloadPlugin)(),
14
14
  (0, vite_tsconfig_paths_1.default)(),
15
15
  ];
16
- exports.currentDir = process.cwd();
17
- exports.srcDir = (0, path_1.join)(exports.currentDir, 'src');
18
- exports.staticDir = (0, path_1.join)(exports.currentDir, 'www-static');
19
- exports.outDir = (0, path_1.join)(exports.currentDir, 'dist');
20
- function findGitRepoRoot(dir = exports.currentDir) {
16
+ function findGitRepoRoot(dir) {
21
17
  if ((0, fs_1.existsSync)((0, path_1.join)(dir, '.git'))) {
22
18
  return dir;
23
19
  }
@@ -29,30 +25,46 @@ function findGitRepoRoot(dir = exports.currentDir) {
29
25
  return findGitRepoRoot(nextDir);
30
26
  }
31
27
  exports.findGitRepoRoot = findGitRepoRoot;
32
- function createBaseConfig({ forGitHubPages }) {
33
- const basePath = forGitHubPages && process.env.CI ? `/${(0, path_1.basename)(findGitRepoRoot())}` : '/';
28
+ function createBaseConfig({ forGitHubPages, packageDirPath }) {
29
+ const cwd = packageDirPath || process.cwd();
30
+ const basePath = forGitHubPages && process.env.CI ? `/${(0, path_1.basename)(findGitRepoRoot(cwd))}` : '/';
31
+ const srcDir = (0, path_1.join)(cwd, 'src');
32
+ const staticDir = (0, path_1.join)(cwd, 'www-static');
33
+ const outDir = (0, path_1.join)(cwd, 'dist');
34
34
  return {
35
- clearScreen: false,
36
- base: basePath,
37
- publicDir: exports.staticDir,
38
- root: exports.srcDir,
39
- plugins: [
40
- ...exports.basePlugins,
41
- ],
42
- build: {
43
- outDir: exports.outDir,
44
- emptyOutDir: true,
35
+ baseConfig: {
36
+ clearScreen: false,
37
+ base: basePath,
38
+ publicDir: staticDir,
39
+ root: srcDir,
40
+ plugins: [
41
+ ...exports.basePlugins,
42
+ ],
43
+ build: {
44
+ outDir,
45
+ emptyOutDir: true,
46
+ },
47
+ },
48
+ basePaths: {
49
+ cwd,
50
+ outDir,
51
+ srcDir,
52
+ staticDir,
45
53
  },
46
54
  };
47
55
  }
48
56
  exports.createBaseConfig = createBaseConfig;
49
57
  async function combineConfigs(baseConfigOptions, overrideCallback) {
50
- const baseConfig = createBaseConfig(baseConfigOptions);
51
- const fullConfig = overrideCallback ? await overrideCallback(baseConfig) : baseConfig;
52
- node_js_1.log.faint(`public dir: ${node_js_1.logColors.info}${(0, path_1.relative)(process.cwd(), fullConfig.publicDir || '')}${node_js_1.logColors.reset}`);
53
- node_js_1.log.faint(`root dir: ${node_js_1.logColors.info}${(0, path_1.relative)(process.cwd(), fullConfig.root || '')}${node_js_1.logColors.reset}`);
54
- node_js_1.log.faint(`out dir: ${node_js_1.logColors.info}${(0, path_1.relative)(process.cwd(), fullConfig.build?.outDir || '')}${node_js_1.logColors.reset}`);
55
- node_js_1.log.faint(`base path: ${node_js_1.logColors.info}${fullConfig.base}${node_js_1.logColors.reset}`);
58
+ const { baseConfig, basePaths } = createBaseConfig(baseConfigOptions);
59
+ const fullConfig = overrideCallback
60
+ ? await overrideCallback(baseConfig, basePaths)
61
+ : baseConfig;
62
+ if (!baseConfigOptions.disableStartupLogs) {
63
+ node_js_1.log.faint(`public dir: ${node_js_1.logColors.info}${(0, path_1.relative)(process.cwd(), fullConfig.publicDir || '')}${node_js_1.logColors.reset}`);
64
+ node_js_1.log.faint(`root dir: ${node_js_1.logColors.info}${(0, path_1.relative)(process.cwd(), fullConfig.root || '')}${node_js_1.logColors.reset}`);
65
+ node_js_1.log.faint(`out dir: ${node_js_1.logColors.info}${(0, path_1.relative)(process.cwd(), fullConfig.build?.outDir || '')}${node_js_1.logColors.reset}`);
66
+ node_js_1.log.faint(`base path: ${node_js_1.logColors.info}${fullConfig.base}${node_js_1.logColors.reset}`);
67
+ }
56
68
  return fullConfig;
57
69
  }
58
70
  exports.combineConfigs = combineConfigs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virmator",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "Handle common package configs, commands, and dependencies.",
5
5
  "keywords": [
6
6
  "automation",