@blazetrails/vite-assets 0.0.0-stage → 0.1.0-alpha0.2

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.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/default.vite.json +27 -0
  3. package/dist/build.d.ts +32 -0
  4. package/dist/build.js +101 -0
  5. package/dist/build.js.map +1 -0
  6. package/dist/builder.d.ts +41 -0
  7. package/dist/builder.js +125 -0
  8. package/dist/builder.js.map +1 -0
  9. package/dist/cli/build.d.ts +6 -0
  10. package/dist/cli/build.js +23 -0
  11. package/dist/cli/build.js.map +1 -0
  12. package/dist/cli/clobber.d.ts +8 -0
  13. package/dist/cli/clobber.js +22 -0
  14. package/dist/cli/clobber.js.map +1 -0
  15. package/dist/cli/command.d.ts +18 -0
  16. package/dist/cli/command.js +19 -0
  17. package/dist/cli/command.js.map +1 -0
  18. package/dist/cli/dev.d.ts +6 -0
  19. package/dist/cli/dev.js +14 -0
  20. package/dist/cli/dev.js.map +1 -0
  21. package/dist/cli/file-utils.d.ts +30 -0
  22. package/dist/cli/file-utils.js +85 -0
  23. package/dist/cli/file-utils.js.map +1 -0
  24. package/dist/cli/install.d.ts +46 -0
  25. package/dist/cli/install.js +165 -0
  26. package/dist/cli/install.js.map +1 -0
  27. package/dist/cli/ssr.d.ts +12 -0
  28. package/dist/cli/ssr.js +37 -0
  29. package/dist/cli/ssr.js.map +1 -0
  30. package/dist/cli/upgrade-packages.d.ts +6 -0
  31. package/dist/cli/upgrade-packages.js +14 -0
  32. package/dist/cli/upgrade-packages.js.map +1 -0
  33. package/dist/cli/upgrade.d.ts +13 -0
  34. package/dist/cli/upgrade.js +43 -0
  35. package/dist/cli/upgrade.js.map +1 -0
  36. package/dist/cli/version.d.ts +6 -0
  37. package/dist/cli/version.js +13 -0
  38. package/dist/cli/version.js.map +1 -0
  39. package/dist/cli/vite.d.ts +19 -0
  40. package/dist/cli/vite.js +62 -0
  41. package/dist/cli/vite.js.map +1 -0
  42. package/dist/cli.d.ts +30 -0
  43. package/dist/cli.js +87 -0
  44. package/dist/cli.js.map +1 -0
  45. package/dist/commands.d.ts +32 -0
  46. package/dist/commands.js +146 -0
  47. package/dist/commands.js.map +1 -0
  48. package/dist/compatibility-check.d.ts +7 -0
  49. package/dist/compatibility-check.js +38 -0
  50. package/dist/compatibility-check.js.map +1 -0
  51. package/dist/config.d.ts +75 -0
  52. package/dist/config.js +199 -0
  53. package/dist/config.js.map +1 -0
  54. package/dist/constants.generated.d.ts +2 -0
  55. package/dist/constants.generated.js +28 -0
  56. package/dist/constants.generated.js.map +1 -0
  57. package/dist/dev-server-proxy.d.ts +31 -0
  58. package/dist/dev-server-proxy.js +89 -0
  59. package/dist/dev-server-proxy.js.map +1 -0
  60. package/dist/error.d.ts +7 -0
  61. package/dist/error.js +16 -0
  62. package/dist/error.js.map +1 -0
  63. package/dist/exe/vite.d.ts +2 -0
  64. package/dist/exe/vite.js +8 -0
  65. package/dist/exe/vite.js.map +1 -0
  66. package/dist/index.d.ts +13 -0
  67. package/dist/index.js +13 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/io.d.ts +11 -0
  70. package/dist/io.js +29 -0
  71. package/dist/io.js.map +1 -0
  72. package/dist/manifest.d.ts +82 -0
  73. package/dist/manifest.js +225 -0
  74. package/dist/manifest.js.map +1 -0
  75. package/dist/missing-entrypoint-error.d.ts +27 -0
  76. package/dist/missing-entrypoint-error.js +48 -0
  77. package/dist/missing-entrypoint-error.js.map +1 -0
  78. package/dist/missing-executable-error.d.ts +5 -0
  79. package/dist/missing-executable-error.js +11 -0
  80. package/dist/missing-executable-error.js.map +1 -0
  81. package/dist/runner.d.ts +21 -0
  82. package/dist/runner.js +80 -0
  83. package/dist/runner.js.map +1 -0
  84. package/dist/tasks/vite.rake.d.ts +2 -0
  85. package/dist/tasks/vite.rake.js +94 -0
  86. package/dist/tasks/vite.rake.js.map +1 -0
  87. package/dist/version.d.ts +4 -0
  88. package/dist/version.js +4 -0
  89. package/dist/version.js.map +1 -0
  90. package/dist/vite-assets.d.ts +116 -0
  91. package/dist/vite-assets.js +238 -0
  92. package/dist/vite-assets.js.map +1 -0
  93. package/package.json +64 -3
  94. package/templates/bin/vite +2 -0
  95. package/templates/config/vite.config.ts +8 -0
  96. package/templates/config/vite.json +16 -0
  97. package/templates/entrypoints/application.js +8 -0
  98. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dean Marano and Trails contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ {
2
+ "additionalEntrypoints": ["~/{assets,fonts,icons,images}/**/*"],
3
+ "assetHost": null,
4
+ "assetsDir": "assets",
5
+ "autoBuild": false,
6
+ "buildCacheDir": "tmp/cache/vite",
7
+ "publicOutputDir": "vite",
8
+ "configPath": "config/vite.json",
9
+ "devServerConnectionCheck": false,
10
+ "devServerConnectTimeout": 0.01,
11
+ "packageManager": null,
12
+ "publicDir": "public",
13
+ "entrypointsDir": "entrypoints",
14
+ "sourceCodeDir": "app/frontend",
15
+ "skipCompatibilityCheck": false,
16
+ "skipProxy": false,
17
+ "host": "localhost",
18
+ "https": null,
19
+ "port": 3036,
20
+ "hideBuildConsoleOutput": false,
21
+ "viteBinPath": null,
22
+ "watchAdditionalPaths": [],
23
+ "base": "",
24
+ "ssrBuildEnabled": false,
25
+ "ssrEntrypoint": "~/ssr/ssr.{js,ts,jsx,tsx}",
26
+ "ssrOutputDir": "public/vite-ssr"
27
+ }
@@ -0,0 +1,32 @@
1
+ import { type Pathname } from "@blazetrails/ruby-compat";
2
+ export interface BuildAttrs {
3
+ success?: boolean | null;
4
+ timestamp?: string | null;
5
+ viteAssets?: string | null;
6
+ digest?: string | null;
7
+ currentDigest?: string | null;
8
+ lastBuildPath?: Pathname | null;
9
+ errors?: unknown;
10
+ }
11
+ export declare class Build {
12
+ success: boolean | null;
13
+ timestamp: string | null;
14
+ viteAssets: string | null;
15
+ digest: string | null;
16
+ currentDigest: string | null;
17
+ lastBuildPath: Pathname | null;
18
+ errors: unknown;
19
+ constructor({ success, timestamp, viteAssets, digest, currentDigest, lastBuildPath, errors, }?: BuildAttrs);
20
+ static fromPrevious(lastBuildPath: Pathname, currentDigest: string): Promise<Build>;
21
+ /** @internal */
22
+ private static parseMetadata;
23
+ /** @internal */
24
+ private static defaultMetadata;
25
+ isStale(): boolean;
26
+ isFresh(): boolean;
27
+ isRetryFailed(): boolean;
28
+ withResult(attrs: BuildAttrs): Build;
29
+ writeToCache(): Promise<void>;
30
+ toJSON(..._args: unknown[]): string;
31
+ }
32
+ //# sourceMappingURL=build.d.ts.map
package/dist/build.js ADDED
@@ -0,0 +1,101 @@
1
+ import { Errno, File } from "@blazetrails/ruby-compat";
2
+ import { VERSION } from "./version.js";
3
+ const MEMBERS = Object.freeze({
4
+ success: "success",
5
+ timestamp: "timestamp",
6
+ vite_ruby: "viteAssets",
7
+ digest: "digest",
8
+ current_digest: "currentDigest",
9
+ last_build_path: "lastBuildPath",
10
+ errors: "errors",
11
+ });
12
+ export class Build {
13
+ success;
14
+ timestamp;
15
+ viteAssets;
16
+ digest;
17
+ currentDigest;
18
+ lastBuildPath;
19
+ errors;
20
+ constructor({ success = null, timestamp = null, viteAssets = null, digest = null, currentDigest = null, lastBuildPath = null, errors = null, } = {}) {
21
+ this.success = success;
22
+ this.timestamp = timestamp;
23
+ this.viteAssets = viteAssets;
24
+ this.digest = digest;
25
+ this.currentDigest = currentDigest;
26
+ this.lastBuildPath = lastBuildPath;
27
+ this.errors = errors;
28
+ }
29
+ static async fromPrevious(lastBuildPath, currentDigest) {
30
+ return new this({
31
+ ...(await this.parseMetadata(lastBuildPath)),
32
+ currentDigest,
33
+ lastBuildPath,
34
+ });
35
+ }
36
+ /** @internal */
37
+ static async parseMetadata(pathname) {
38
+ try {
39
+ if (!(await File.isExistAsync(pathname.toString())))
40
+ return this.defaultMetadata();
41
+ const metadata = {};
42
+ for (const [key, value] of Object.entries(JSON.parse(await pathname.read()))) {
43
+ if (Object.hasOwn(MEMBERS, key))
44
+ metadata[MEMBERS[key]] = value;
45
+ }
46
+ return metadata;
47
+ }
48
+ catch (error) {
49
+ if (error instanceof SyntaxError ||
50
+ error instanceof Errno.ENOENT ||
51
+ error instanceof Errno.ENOTDIR) {
52
+ return this.defaultMetadata();
53
+ }
54
+ throw error;
55
+ }
56
+ }
57
+ /** @internal */
58
+ static defaultMetadata() {
59
+ return { timestamp: "never", digest: "none" };
60
+ }
61
+ isStale() {
62
+ return (this.digest !== this.currentDigest || this.isRetryFailed() || this.viteAssets !== VERSION);
63
+ }
64
+ isFresh() {
65
+ return !this.isStale();
66
+ }
67
+ isRetryFailed() {
68
+ if (this.success)
69
+ return false;
70
+ const time = new Date(String(this.timestamp).replace(" ", "T"));
71
+ if (Number.isNaN(time.getTime()))
72
+ return true;
73
+ return time.getTime() + 3 * 1000 < Date.now();
74
+ }
75
+ withResult(attrs) {
76
+ const now = new Date();
77
+ const pad = (n) => String(n).padStart(2, "0");
78
+ return new this.constructor({
79
+ ...attrs,
80
+ timestamp: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ` +
81
+ `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`,
82
+ viteAssets: VERSION,
83
+ digest: this.currentDigest,
84
+ currentDigest: this.currentDigest,
85
+ lastBuildPath: this.lastBuildPath,
86
+ });
87
+ }
88
+ async writeToCache() {
89
+ await this.lastBuildPath.write(this.toJSON());
90
+ }
91
+ toJSON(..._args) {
92
+ return JSON.stringify({
93
+ success: this.success,
94
+ errors: this.errors,
95
+ timestamp: this.timestamp,
96
+ vite_ruby: this.viteAssets,
97
+ digest: this.digest,
98
+ }, null, 2);
99
+ }
100
+ }
101
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../lib/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAiB,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAYvC,MAAM,OAAO,GAA+C,MAAM,CAAC,MAAM,CAAC;IACxE,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,YAAY;IACvB,MAAM,EAAE,QAAQ;IAChB,cAAc,EAAE,eAAe;IAC/B,eAAe,EAAE,eAAe;IAChC,MAAM,EAAE,QAAQ;CACjB,CAAC,CAAC;AAEH,MAAM,OAAO,KAAK;IAChB,OAAO,CAAiB;IACxB,SAAS,CAAgB;IACzB,UAAU,CAAgB;IAC1B,MAAM,CAAgB;IACtB,aAAa,CAAgB;IAC7B,aAAa,CAAkB;IAC/B,MAAM,CAAU;IAEhB,YAAY,EACV,OAAO,GAAG,IAAI,EACd,SAAS,GAAG,IAAI,EAChB,UAAU,GAAG,IAAI,EACjB,MAA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AAK;YACR,SAAS,EACP,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG;gBACxE,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE;YAC5E,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,IAAI,CAAC,aAAa;YAC1B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,aAAc,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,GAAG,KAAgB;QACxB,OAAO,IAAI,CAAC,SAAS,CACnB;YACE,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,EACD,IAAI,EACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ import { Build } from "./build.js";
2
+ import type { ViteAssets } from "./vite-assets.js";
3
+ export declare class Builder {
4
+ /** @internal */
5
+ private readonly _viteAssets;
6
+ /** @internal */
7
+ private _fileDigests;
8
+ /** @internal */
9
+ private _lastDigest;
10
+ /** @internal */
11
+ private _lastDigestAt;
12
+ constructor(viteAssets: ViteAssets);
13
+ build(...args: string[]): Promise<boolean>;
14
+ lastBuildMetadata({ ssr }?: {
15
+ ssr?: boolean;
16
+ }): Promise<Build>;
17
+ /** @internal */
18
+ private config;
19
+ /** @internal */
20
+ private get logger();
21
+ /** @internal */
22
+ private run;
23
+ /** @internal */
24
+ private recordBuildMetadata;
25
+ /** @internal */
26
+ private lastBuildPath;
27
+ /**
28
+ * @internal
29
+ * @missingRailsCall within_root — PERMANENT
30
+ */
31
+ watchedFilesDigest(): Promise<string>;
32
+ /** @internal */
33
+ private fileDigest;
34
+ /** @internal */
35
+ private isRecentlyModified;
36
+ /** @internal */
37
+ private buildWithVite;
38
+ /** @internal */
39
+ private logBuildResult;
40
+ }
41
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1,125 @@
1
+ import { Digest, Dir, File, FileUtils, getFs, } from "@blazetrails/ruby-compat";
2
+ import { Build } from "./build.js";
3
+ export class Builder {
4
+ /** @internal */
5
+ _viteAssets;
6
+ /** @internal */
7
+ _fileDigests = Object.create(null);
8
+ /** @internal */
9
+ _lastDigest;
10
+ /** @internal */
11
+ _lastDigestAt;
12
+ constructor(viteAssets) {
13
+ this._viteAssets = viteAssets;
14
+ }
15
+ async build(...args) {
16
+ const lastBuild = await this.lastBuildMetadata({ ssr: args.includes("--ssr") });
17
+ const force = args.includes("--force");
18
+ args = args.filter((arg) => arg !== "--force");
19
+ if (force || lastBuild.isStale() || (await this.config().manifestPaths()).length === 0) {
20
+ const [stdout, stderr, status] = await this.buildWithVite(...args);
21
+ await this.logBuildResult(stdout, stderr, status);
22
+ await this.recordBuildMetadata(lastBuild, { errors: stderr, success: status.isSuccess() });
23
+ return status.isSuccess();
24
+ }
25
+ else if (lastBuild.success) {
26
+ this.logger.debug(`Skipping vite build. Watched files have not changed since the last build at ${lastBuild.timestamp}`);
27
+ return true;
28
+ }
29
+ else {
30
+ this.logger.error(`Skipping vite build. Watched files have not changed since the build failed at ${lastBuild.timestamp} ❌`);
31
+ return false;
32
+ }
33
+ }
34
+ async lastBuildMetadata({ ssr = false } = {}) {
35
+ return Build.fromPrevious(await this.lastBuildPath({ ssr }), await this.watchedFilesDigest());
36
+ }
37
+ /** @internal */
38
+ config() {
39
+ return this._viteAssets.config();
40
+ }
41
+ /** @internal */
42
+ get logger() {
43
+ return this._viteAssets.logger;
44
+ }
45
+ /** @internal */
46
+ run(argv) {
47
+ return this._viteAssets.run(argv);
48
+ }
49
+ /** @internal */
50
+ async recordBuildMetadata(build, attrs) {
51
+ await FileUtils.mkpathAsync(this.config().buildCacheDir.toString());
52
+ await build.withResult(attrs).writeToCache();
53
+ }
54
+ /** @internal */
55
+ async lastBuildPath({ ssr }) {
56
+ const config = this.config();
57
+ return config.buildCacheDir.join(`last${ssr ? "-ssr" : ""}-build-${config.mode}.json`);
58
+ }
59
+ /**
60
+ * @internal
61
+ * @missingRailsCall within_root — PERMANENT
62
+ */
63
+ async watchedFilesDigest() {
64
+ if (this._lastDigestAt !== undefined && Date.now() - this._lastDigestAt < 1000) {
65
+ return this._lastDigest;
66
+ }
67
+ const config = this.config();
68
+ const root = File.expandPath(config.root.toString());
69
+ const previousDigests = this._fileDigests;
70
+ this._fileDigests = Object.create(null);
71
+ const files = [];
72
+ for (const pattern of config.watchedPaths()) {
73
+ files.push(...(await Dir.globAsync(pattern, 0, { base: root })).map((file) => File.join(root, file)));
74
+ }
75
+ const fileIds = [];
76
+ for (const file of files.sort()) {
77
+ const id = await this.fileDigest(file, previousDigests);
78
+ if (id != null)
79
+ fileIds.push(id);
80
+ }
81
+ this._lastDigestAt = Date.now();
82
+ return (this._lastDigest = Digest.SHA1.hexdigest(fileIds.join("/")));
83
+ }
84
+ /** @internal */
85
+ async fileDigest(file, previousDigests) {
86
+ const stat = await getFs().stat(file);
87
+ if (stat.isDirectory())
88
+ return null;
89
+ const signature = [stat.mtime.getTime(), stat.size];
90
+ const [previousSignature, previousId] = previousDigests[file] ?? [];
91
+ const id = previousSignature?.[0] === signature[0] &&
92
+ previousSignature[1] === signature[1] &&
93
+ !this.isRecentlyModified(stat)
94
+ ? previousId
95
+ : `${File.basename(file)}/${(await Digest.SHA1.file(file)).hexdigest()}`;
96
+ this._fileDigests[file] = [signature, id];
97
+ return id;
98
+ }
99
+ /** @internal */
100
+ isRecentlyModified(stat) {
101
+ return Date.now() - stat.mtime.getTime() < 1000;
102
+ }
103
+ /** @internal */
104
+ async buildWithVite(...args) {
105
+ this.logger.info("Building with Vite ⚡️");
106
+ return (await this.run(["build", ...args]));
107
+ }
108
+ /** @internal */
109
+ async logBuildResult(_stdout, stderr, status) {
110
+ if (status.isSuccess()) {
111
+ this.logger.info(`Build with Vite complete: ${this.config().buildOutputDir()}`);
112
+ if (stderr !== "")
113
+ this.logger.error(stderr);
114
+ }
115
+ else {
116
+ this.logger.error(stderr);
117
+ this.logger.error(status);
118
+ this.logger.error("Build with Vite failed! ❌");
119
+ if (stderr.includes("ERR! canceled")) {
120
+ this.logger.error("❌ Check that vite and vite-plugin-ruby are in devDependencies and have been installed. ");
121
+ }
122
+ }
123
+ }
124
+ }
125
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../lib/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,SAAS,EACT,KAAK,GAIN,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAY,CAAC;AAMpD,MAAM,OAAO,OAAO;IAClB,gBAAgB;IACC,WAAW,CAAa;IACzC,gBAAgB;IACR,YAAY,GAAwC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChF,gBAAgB;IACR,WAAW,CAAqB;IACxC,gBAAgB;IACR,aAAa,CAAqB;IAE1C,YAAY,UAAsB;QAChC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,GAAG,IAAc;QAC3B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,OAA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AAE,EAAE,CAAC,CAAC;YAChF,IAAI,MAAM,KAAK,EAAE;gBAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC/C,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;gBACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,yFAAyF,CAC1F,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { Vite, type ViteOptions } from "./vite.js";
2
+ export declare class Build extends Vite {
3
+ static readonly DEFAULT_ENV: string;
4
+ call(options: ViteOptions): Promise<unknown>;
5
+ }
6
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { ViteAssets } from "../vite-assets.js";
2
+ import { Vite } from "./vite.js";
3
+ export class Build extends Vite {
4
+ static DEFAULT_ENV = Vite.CURRENT_ENV || "production";
5
+ static {
6
+ this.desc("Bundle all entrypoints using Vite.");
7
+ this.sharedOptions();
8
+ this.option("ssr", { desc: "Build the SSR entrypoint instead", type: "boolean" });
9
+ this.option("force", {
10
+ desc: "Force the build even if assets have not changed",
11
+ type: "boolean",
12
+ });
13
+ this.option("watch", {
14
+ desc: "Start the Rollup watcher and rebuild on files changes",
15
+ type: "boolean",
16
+ });
17
+ this.option("profile", { desc: "Gather performance metrics from the build ", type: "boolean" });
18
+ }
19
+ call(options) {
20
+ return super.call(options, (args) => ViteAssets.commands().buildFromTask(...args));
21
+ }
22
+ }
23
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../lib/cli/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAoB,MAAM,WAAW,CAAC;AAEnD,MAAM,OAAO,KAAM,SAAQ,IAAI;IAC7B,MAAM,CAAmB,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,YAAY,CAAC;IAExE;QACE,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,kCAAkC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAClF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,IAAI,EAAE,iDAAiD;YACvD,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,IAAI,EAAE,uDAAuD;YAC7D,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,4CAA4C,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAClG,CAAC;IAEQ,IAAI,CAAC,OAAoB;QAChC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { Command } from "./command.js";
2
+ export declare class Clobber extends Command {
3
+ /** @inventedArm prewarmConfig — PERMANENT */
4
+ call({ mode }: {
5
+ mode: string;
6
+ }): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=clobber.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { env as ENV } from "@blazetrails/ruby-compat";
2
+ import { ViteAssets } from "../vite-assets.js";
3
+ import { Command } from "./command.js";
4
+ export class Clobber extends Command {
5
+ static {
6
+ this.desc("Clear the Vite cache, temp files, and builds");
7
+ const currentEnv = ENV["RACK_ENV"] || ENV["TRAILS_ENV"] || "development";
8
+ this.option("mode", {
9
+ default: currentEnv,
10
+ values: ["development", "production", "test"],
11
+ aliases: ["m"],
12
+ desc: "The mode to use",
13
+ });
14
+ }
15
+ /** @inventedArm prewarmConfig — PERMANENT */
16
+ async call({ mode }) {
17
+ ViteAssets.env()["VITE_RUBY_MODE"] = mode;
18
+ await ViteAssets.prewarmConfig();
19
+ return ViteAssets.commands().clobber();
20
+ }
21
+ }
22
+ //# sourceMappingURL=clobber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clobber.js","sourceRoot":"","sources":["../../lib/cli/clobber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,OAAQ,SAAQ,OAAO;IAClC;QACE,IAAI,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAE1D,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,aAAa,CAAC;QAEzE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,OAAO,EAAE,UAAU;YACnB,MAAM,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC;YAC7C,OAAO,EAAE,CAAC,GAAG,CAAC;YACd,IAAI,EAAE,iBAAiB;SACxB,CAAC,CAAC;IACL,CAAC;IAED,6CAA6C;IACpC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAoB;QAC5C,UAAU,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,UAAU,CAAC,aAAa,EAAE,CAAC;QACjC,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ export interface CommandOption {
2
+ type?: "boolean" | "string";
3
+ default?: unknown;
4
+ values?: string[];
5
+ aliases?: string[];
6
+ desc?: string;
7
+ }
8
+ /** @noRailsEquivalent PERMANENT */
9
+ export declare class Command {
10
+ /** @internal */
11
+ static _description: string | null;
12
+ /** @internal */
13
+ static _options: Record<string, CommandOption>;
14
+ static desc(description: string): void;
15
+ static option(name: string, options?: CommandOption): void;
16
+ call(_options: Record<string, unknown>): unknown;
17
+ }
18
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** @noRailsEquivalent PERMANENT */
2
+ export class Command {
3
+ /** @internal */
4
+ static _description = null;
5
+ /** @internal */
6
+ static _options = {};
7
+ static desc(description) {
8
+ this._description = description;
9
+ }
10
+ static option(name, options = {}) {
11
+ if (!Object.hasOwn(this, "_options"))
12
+ this._options = { ...this._options };
13
+ this._options[name] = options;
14
+ }
15
+ call(_options) {
16
+ return undefined;
17
+ }
18
+ }
19
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../lib/cli/command.ts"],"names":[],"mappings":"AAQA,mCAAmC;AACnC,MAAM,OAAO,OAAO;IAClB,gBAAgB;IAChB,MAAM,CAAC,YAAY,GAAkB,IAAI,CAAC;IAC1C,gBAAgB;IAChB,MAAM,CAAC,QAAQ,GAAkC,EAAE,CAAC;IAEpD,MAAM,CAAC,IAAI,CAAC,WAAmB;QAC7B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,IAAY,EAAE,OAAO,GAAkB,EAAE;QACrD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC;YAAE,IAAI,CAAC,QAAQ,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC3E,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,IAAI,CAAC,QAAiC;QACpC,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { Vite, type ViteOptions } from "./vite.js";
2
+ export declare class Dev extends Vite {
3
+ static readonly DEFAULT_ENV: string;
4
+ call(options: ViteOptions): Promise<unknown>;
5
+ }
6
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { ViteAssets } from "../vite-assets.js";
2
+ import { Vite } from "./vite.js";
3
+ export class Dev extends Vite {
4
+ static DEFAULT_ENV = Vite.CURRENT_ENV || "development";
5
+ static {
6
+ this.desc("Start the Vite development server.");
7
+ this.sharedOptions();
8
+ this.option("force", { desc: "Force Vite to re-bundle dependencies", type: "boolean" });
9
+ }
10
+ call(options) {
11
+ return super.call(options, (args) => ViteAssets.run(args, { exec: true }));
12
+ }
13
+ }
14
+ //# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../lib/cli/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAoB,MAAM,WAAW,CAAC;AAEnD,MAAM,OAAO,GAAI,SAAQ,IAAI;IAC3B,MAAM,CAAmB,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,aAAa,CAAC;IAEzE;QACE,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,sCAAsC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1F,CAAC;IAEQ,IAAI,CAAC,OAAoB;QAChC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { Pathname } from "@blazetrails/ruby-compat";
2
+ type Path = Pathname | string;
3
+ type Finder = (content: string[], path: Path, target: string) => number;
4
+ export declare const FileUtils: {
5
+ /** @missingRailsArgs join — PERMANENT */
6
+ write(path: Path, ...content: (string | string[])[]): Promise<void>;
7
+ cp(source: Path, destination: Path): Promise<void>;
8
+ append(path: Path, contents: string): Promise<void>;
9
+ appendUnlessPresent(path: Path, contents: string, { pattern }: {
10
+ pattern: string;
11
+ }): Promise<void>;
12
+ replaceFirstLine(path: Path, target: string, replacement: string): Promise<void>;
13
+ injectLineBefore(path: Path, target: string, contents: string): Promise<void>;
14
+ injectLineAfter(path: Path, target: string, contents: string): Promise<void>;
15
+ injectLineAfterLast(path: Path, target: string, contents: string): Promise<void>;
16
+ /** @internal */
17
+ mkdirP(path: Path): Promise<void>;
18
+ /** @internal */
19
+ readLines(path: Path): Promise<string[]>;
20
+ /** @internal */
21
+ index(content: string[], path: Path, target: string): number;
22
+ /** @internal */
23
+ rindex(content: string[], path: Path, target: string): number;
24
+ /** @internal */
25
+ _injectLineBefore(path: Path, target: string, contents: string, finder: Finder): Promise<void>;
26
+ /** @internal */
27
+ _injectLineAfter(path: Path, target: string, contents: string, finder: Finder): Promise<void>;
28
+ };
29
+ export {};
30
+ //# sourceMappingURL=file-utils.d.ts.map
@@ -0,0 +1,85 @@
1
+ import { ArgumentError, File, FileUtils as RbFileUtils, Pathname } from "@blazetrails/ruby-compat";
2
+ export const FileUtils = {
3
+ /** @missingRailsArgs join — PERMANENT */
4
+ async write(path, ...content) {
5
+ await FileUtils.mkdirP(path);
6
+ await File.writeAsync(path.toString(), content.flat().join(""));
7
+ },
8
+ async cp(source, destination) {
9
+ await FileUtils.mkdirP(destination);
10
+ if (!(await File.isExistAsync(destination.toString()))) {
11
+ await RbFileUtils.cpAsync(source.toString(), destination.toString());
12
+ }
13
+ },
14
+ append(path, contents) {
15
+ return FileUtils.appendUnlessPresent(path, contents, { pattern: contents });
16
+ },
17
+ async appendUnlessPresent(path, contents, { pattern }) {
18
+ const content = await FileUtils.readLines(path);
19
+ if (content.some((line) => line.includes(pattern)))
20
+ return;
21
+ if (!content.at(-1)?.endsWith("\n"))
22
+ content.push("\n");
23
+ content.push(`${contents}\n`);
24
+ await FileUtils.write(path, content);
25
+ },
26
+ async replaceFirstLine(path, target, replacement) {
27
+ const content = await FileUtils.readLines(path);
28
+ content[FileUtils.index(content, path, target)] = `${replacement}\n`;
29
+ await FileUtils.write(path, content);
30
+ },
31
+ injectLineBefore(path, target, contents) {
32
+ return FileUtils._injectLineBefore(path, target, contents, FileUtils.index);
33
+ },
34
+ injectLineAfter(path, target, contents) {
35
+ return FileUtils._injectLineAfter(path, target, contents, FileUtils.index);
36
+ },
37
+ injectLineAfterLast(path, target, contents) {
38
+ return FileUtils._injectLineAfter(path, target, contents, FileUtils.rindex);
39
+ },
40
+ /** @internal */
41
+ async mkdirP(path) {
42
+ await new Pathname(path).dirname().mkpath();
43
+ },
44
+ /** @internal */
45
+ async readLines(path) {
46
+ return (await File.isExistAsync(path.toString()))
47
+ ? await File.readlinesAsync(path.toString())
48
+ : [];
49
+ },
50
+ /** @internal */
51
+ index(content, path, target) {
52
+ const i = content.findIndex((line) => line.includes(target));
53
+ if (i === -1)
54
+ throw new ArgumentError(`Cannot find \`${target}' inside \`${path}'.`);
55
+ return i;
56
+ },
57
+ /** @internal */
58
+ rindex(content, path, target) {
59
+ let i = content.length - 1;
60
+ while (i >= 0 && !content[i].includes(target))
61
+ i--;
62
+ if (i === -1)
63
+ throw new ArgumentError(`Cannot find \`${target}' inside \`${path}'.`);
64
+ return i;
65
+ },
66
+ /** @internal */
67
+ async _injectLineBefore(path, target, contents, finder) {
68
+ const content = await FileUtils.readLines(path);
69
+ if (content.join("").includes(contents))
70
+ return;
71
+ const i = finder(content, path, target);
72
+ content.splice(i, 0, `${contents}\n`);
73
+ await FileUtils.write(path, content);
74
+ },
75
+ /** @internal */
76
+ async _injectLineAfter(path, target, contents, finder) {
77
+ const content = await FileUtils.readLines(path);
78
+ if (content.join("").includes(contents))
79
+ return;
80
+ const i = finder(content, path, target);
81
+ content.splice(i + 1, 0, `${contents}\n`);
82
+ await FileUtils.write(path, content);
83
+ },
84
+ };
85
+ //# sourceMappingURL=file-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../lib/cli/file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAKnG,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,yCAAyC;IACzC,KAAK,CAAC,KAAK,CAAC,IAAU,EAAE,GAAG,OAA8B;QACvD,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,EAAE,CAAC,MAAY,EAAE,WAAiB;QACtC,MAAM,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACpC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;YACvD,MAAM,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,MAAM,CAAC,IAA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