create-lt-adventure 0.0.16 → 0.1.3
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.
- package/README.md +85 -85
- package/addons/github-workflow/addon.json +5 -5
- package/addons/github-workflow/main.yml +96 -48
- package/addons/github-workflow/{setup.ts → setup.mjs} +115 -112
- package/addons/sf2e-pf2e-redirects/addon.json +5 -0
- package/addons/sf2e-pf2e-redirects/setup.mjs +119 -0
- package/dist/bin.js +223 -84
- package/dist/bin.js.map +1 -1
- package/dist/migrate.d.ts +2 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +169 -0
- package/dist/migrate.js.map +1 -0
- package/dist/options.d.ts +5 -2
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +14 -5
- package/dist/options.js.map +1 -1
- package/package.json +68 -66
- package/templates/vite/.env.example +1 -1
- package/templates/vite/CHANGELOG +1 -0
- package/templates/vite/gitignore +37 -37
- package/templates/vite/module.json +37 -36
- package/templates/vite/package.json +3 -2
- package/templates/vite/scripts/extractPacks.mjs +54 -49
- package/templates/vite/scripts/jsonReplacer.mjs +11 -0
- package/templates/vite/scripts/onCreate.mjs +41 -13
- package/templates/vite/scripts/symlink.mjs +78 -78
- package/templates/vite/src/adventureSheet/index.js +497 -497
- package/templates/vite/src/hooks.ts +22 -0
- package/templates/vite/src/index.js +4 -4
- package/templates/vite/src/lib/utils.ts +1 -0
- package/templates/vite/src/misc/prosemirror.js +46 -46
- package/templates/vite/src/module.css +306 -306
- package/templates/vite/src/types.d.ts +7 -7
- package/templates/vite/tsconfig.json +33 -29
- package/templates/vite/vite.config.ts +129 -128
- package/templates/vite/bun.lock +0 -802
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
4
|
-
"target": "esnext",
|
|
5
|
-
"module": "esnext",
|
|
6
|
-
"moduleDetection": "force",
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"declaration": true,
|
|
9
|
-
"declarationMap": true,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"rootDir": "./src",
|
|
13
|
-
"allowJs": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"strict": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"noFallthroughCasesInSwitch": true,
|
|
18
|
-
"noUncheckedIndexedAccess": true,
|
|
19
|
-
"noImplicitOverride": true,
|
|
20
|
-
"noUnusedLocals": false,
|
|
21
|
-
"noUnusedParameters": false,
|
|
22
|
-
"noPropertyAccessFromIndexSignature": false,
|
|
23
|
-
"esModuleInterop": true,
|
|
24
|
-
"allowSyntheticDefaultImports": true,
|
|
25
|
-
"types": ["@7h3laughingman/foundry-types", "jquery"],
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
"moduleDetection": "force",
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"strict": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"noUncheckedIndexedAccess": true,
|
|
19
|
+
"noImplicitOverride": true,
|
|
20
|
+
"noUnusedLocals": false,
|
|
21
|
+
"noUnusedParameters": false,
|
|
22
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
23
|
+
"esModuleInterop": true,
|
|
24
|
+
"allowSyntheticDefaultImports": true,
|
|
25
|
+
"types": ["@7h3laughingman/foundry-types", "jquery", "vite/client"],
|
|
26
|
+
"paths": {
|
|
27
|
+
"$lib/*": ["./src/lib/*"],
|
|
28
|
+
"moduleJSON": ["./module.json"]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"include": ["src/**/*"],
|
|
32
|
+
"exclude": ["node_modules", "dist"],
|
|
33
|
+
}
|
|
@@ -1,128 +1,129 @@
|
|
|
1
|
-
import type { Plugin, UserConfig } from "vite";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import vttSync from "foundryvtt-sync";
|
|
5
|
-
import postcssPresetEnv from "postcss-preset-env";
|
|
6
|
-
import PostCSSReplace from "postcss-replace";
|
|
7
|
-
import { defineConfig } from "vite";
|
|
8
|
-
import moduleJSON from "./module.json" with { type: "json" };
|
|
9
|
-
import "dotenv/config";
|
|
10
|
-
|
|
11
|
-
const target = "es2022"; // Build target for the
|
|
12
|
-
const foundryPort = Number(process.env.FOUNDRY_PORT || 30000); // Which port your FoundryVTT instance is hosted at.
|
|
13
|
-
const devPort = Number(process.env.DEV_PORT || 30001); // Which port you want to use for development.
|
|
14
|
-
const libEntry = "index.js"; // The main entry file to begin crawling from (root being `src/`).
|
|
15
|
-
|
|
16
|
-
const postcss = {
|
|
17
|
-
inject: false,
|
|
18
|
-
sourceMap: true,
|
|
19
|
-
extensions: [".css"],
|
|
20
|
-
plugins: [
|
|
21
|
-
postcssPresetEnv,
|
|
22
|
-
PostCSSReplace({
|
|
23
|
-
pattern: /\(\(\s?(\S+?)\s?\)\)/g,
|
|
24
|
-
commentsOnly: false,
|
|
25
|
-
data: {
|
|
26
|
-
moduleId: moduleJSON.id,
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const PACKAGE_ID = `modules/${moduleJSON.id}`;
|
|
33
|
-
|
|
34
|
-
export default defineConfig(({ mode: _mode }) => {
|
|
35
|
-
if (_mode === "serve") console.log(`Running foundry port ${foundryPort} -> dev port ${devPort}`);
|
|
36
|
-
return {
|
|
37
|
-
root: "src/", // Source location / esbuild root.
|
|
38
|
-
base: `/${PACKAGE_ID}/dist`, // Base module path.
|
|
39
|
-
publicDir: false, // No public resources to copy.
|
|
40
|
-
cacheDir: "../.vite-cache", // Relative from root directory.
|
|
41
|
-
|
|
42
|
-
resolve: {
|
|
43
|
-
conditions: ["browser", "import", "default"], // Only use browser-compatible exports from node modules.
|
|
44
|
-
alias: {
|
|
45
|
-
$lib: path.resolve(__dirname, "./src/lib"),
|
|
46
|
-
moduleJSON: path.resolve(__dirname, "./module.json"),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
res.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
1
|
+
import type { Plugin, UserConfig } from "vite";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import vttSync from "foundryvtt-sync";
|
|
5
|
+
import postcssPresetEnv from "postcss-preset-env";
|
|
6
|
+
import PostCSSReplace from "postcss-replace";
|
|
7
|
+
import { defineConfig } from "vite";
|
|
8
|
+
import moduleJSON from "./module.json" with { type: "json" };
|
|
9
|
+
import "dotenv/config";
|
|
10
|
+
|
|
11
|
+
const target = "es2022"; // Build target for the final bundle.
|
|
12
|
+
const foundryPort = Number(process.env.FOUNDRY_PORT || 30000); // Which port your FoundryVTT instance is hosted at.
|
|
13
|
+
const devPort = Number(process.env.DEV_PORT || 30001); // Which port you want to use for development.
|
|
14
|
+
const libEntry = "index.js"; // The main entry file to begin crawling from (root being `src/`).
|
|
15
|
+
|
|
16
|
+
const postcss = {
|
|
17
|
+
inject: false,
|
|
18
|
+
sourceMap: true,
|
|
19
|
+
extensions: [".css"],
|
|
20
|
+
plugins: [
|
|
21
|
+
postcssPresetEnv,
|
|
22
|
+
PostCSSReplace({
|
|
23
|
+
pattern: /\(\(\s?(\S+?)\s?\)\)/g,
|
|
24
|
+
commentsOnly: false,
|
|
25
|
+
data: {
|
|
26
|
+
moduleId: moduleJSON.id,
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const PACKAGE_ID = `modules/${moduleJSON.id}`;
|
|
33
|
+
|
|
34
|
+
export default defineConfig(({ mode: _mode }) => {
|
|
35
|
+
if (_mode === "serve") console.log(`Running foundry port ${foundryPort} -> dev port ${devPort}`);
|
|
36
|
+
return {
|
|
37
|
+
root: "src/", // Source location / esbuild root.
|
|
38
|
+
base: `/${PACKAGE_ID}/dist`, // Base module path.
|
|
39
|
+
publicDir: false, // No public resources to copy.
|
|
40
|
+
cacheDir: "../.vite-cache", // Relative from root directory.
|
|
41
|
+
|
|
42
|
+
resolve: {
|
|
43
|
+
conditions: ["browser", "import", "default"], // Only use browser-compatible exports from node modules.
|
|
44
|
+
alias: {
|
|
45
|
+
$lib: path.resolve(__dirname, "./src/lib"),
|
|
46
|
+
moduleJSON: path.resolve(__dirname, "./module.json"),
|
|
47
|
+
// Modify also the tsconfig.json file to include the alias
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
esbuild: { target }, // https://esbuild.github.io/api/#transform
|
|
52
|
+
|
|
53
|
+
css: { postcss }, // https://vite.dev/config/shared-options#css-postcss
|
|
54
|
+
|
|
55
|
+
server: {
|
|
56
|
+
port: devPort,
|
|
57
|
+
open: "/game",
|
|
58
|
+
proxy: {
|
|
59
|
+
// Serves static files from main Foundry server.
|
|
60
|
+
[`^(/${PACKAGE_ID}/(assets|lang|packs))`]: `http://localhost:${foundryPort}`,
|
|
61
|
+
|
|
62
|
+
// All other paths besides package ID path are served from main Foundry server.
|
|
63
|
+
[`^(?!/${PACKAGE_ID}/)`]: `http://localhost:${foundryPort}`,
|
|
64
|
+
|
|
65
|
+
// Rewrite incoming `module-id.js` request from Foundry to the dev server libEntry.
|
|
66
|
+
[`/${PACKAGE_ID}/dist/${moduleJSON.id}.js`]: {
|
|
67
|
+
target: `http://localhost:${devPort}/${PACKAGE_ID}/dist`,
|
|
68
|
+
rewrite: () => libEntry,
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
// Enable socket.io from main Foundry server.
|
|
72
|
+
"/socket.io": { target: `ws://localhost:${foundryPort}`, ws: true },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
build: {
|
|
76
|
+
outDir: "../dist", // The output directory.
|
|
77
|
+
emptyOutDir: true,
|
|
78
|
+
sourcemap: true, // Provide a publicly available sourcemap for debuggin purposes.
|
|
79
|
+
target,
|
|
80
|
+
minify: "terser",
|
|
81
|
+
terserOptions: {
|
|
82
|
+
keep_classnames: true, // Don't mangle class names since Foundry relies on them
|
|
83
|
+
},
|
|
84
|
+
lib: {
|
|
85
|
+
entry: `./${libEntry}`,
|
|
86
|
+
formats: ["es"],
|
|
87
|
+
fileName: moduleJSON.id,
|
|
88
|
+
},
|
|
89
|
+
rollupOptions: {
|
|
90
|
+
output: {
|
|
91
|
+
// Rewrite the default style.css to a more recognizable file name.
|
|
92
|
+
assetFileNames: assetInfo =>
|
|
93
|
+
assetInfo.name === "style.css" ? `${moduleJSON.id}.css` : assetInfo.name as string,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
plugins: [
|
|
99
|
+
vttSync(moduleJSON, { ignoreAdventureHMR: true }), // Build the database from JSON files on build
|
|
100
|
+
{
|
|
101
|
+
name: "create-dist-files", // Create dummy files for Foundry's tests to pass
|
|
102
|
+
apply: "serve",
|
|
103
|
+
buildStart() {
|
|
104
|
+
if (!fs.existsSync("dist")) fs.mkdirSync("dist");
|
|
105
|
+
|
|
106
|
+
const files = [...moduleJSON.esmodules, ...moduleJSON.styles];
|
|
107
|
+
for (const name of files) {
|
|
108
|
+
fs.writeFileSync(name, "", { flag: "a" });
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'empty-css-proxy', // Create dummy CSS responses for Foundry requests
|
|
114
|
+
apply: 'serve',
|
|
115
|
+
configureServer(server) {
|
|
116
|
+
server.middlewares.use((req, res, next) => {
|
|
117
|
+
const cssPath = `/${PACKAGE_ID}/dist/${moduleJSON.id}.css`;
|
|
118
|
+
if (req.url === cssPath) {
|
|
119
|
+
res.setHeader('Content-Type', 'text/css');
|
|
120
|
+
res.end('');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
next();
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
} satisfies UserConfig;
|
|
129
|
+
});
|