Fixed scripts to work with packages

This commit is contained in:
Prozilla 2024-07-06 20:44:05 +02:00
parent 001d382863
commit aaa394fcd8
No known key found for this signature in database
GPG key ID: 5858DFE71CAF31EE
8 changed files with 61 additions and 55 deletions

View file

@ -61,7 +61,7 @@ These scripts are related to the website and its lifecycle.
Compile project using TypeScript and bundle all files into the `dist` directory, or the directory specified in config file. This directory can be uploaded to a web server.
3. `pnpm run serve`
3. `pnpm run preview`
Start web server with preview of build at [localhost:8080](http://localhost:8080/). Can be useful for testing build before deploying.

View file

@ -12,11 +12,11 @@
"preinstall": "npx only-allow pnpm",
"start": "vite",
"build": "tsc && vite build",
"serve": "vite preview --port 8080",
"stage": "tsx scripts/stage",
"preview": "vite preview --port 8080",
"stage": "vite-node scripts/stage",
"predeploy": "pnpm run build && pnpm run stage",
"deploy": "tsx scripts/deploy",
"fetch": "tsx scripts/fetchRepository",
"deploy": "vite-node scripts/deploy",
"fetch": "vite-node scripts/fetchRepository",
"packages:build": "pnpm -r --sequential run build",
"packages:update": "npx changeset && pnpm changeset version",
"packages:release": "pnpm changeset publish"
@ -58,9 +58,9 @@
"eslint-plugin-react-refresh": "^0.4.7",
"gh-pages": "^6.1.1",
"stylelint": "^16.6.1",
"tsx": "^4.15.6",
"typescript": "^5.4.5",
"typescript-eslint": "^7.13.1",
"vite-node": "^1.6.0",
"vite-plugin-checker": "^0.7.1"
},
"browserslist": {

View file

@ -87,15 +87,15 @@ importers:
stylelint:
specifier: ^16.6.1
version: 16.6.1(typescript@5.4.5)
tsx:
specifier: ^4.15.6
version: 4.15.6
typescript:
specifier: ^5.4.5
version: 5.4.5
typescript-eslint:
specifier: ^7.13.1
version: 7.13.1(eslint@8.57.0)(typescript@5.4.5)
vite-node:
specifier: ^1.6.0
version: 1.6.0(@types/node@20.14.6)(less@4.2.0)
vite-plugin-checker:
specifier: ^0.7.1
version: 0.7.1(eslint@8.57.0)(optionator@0.9.4)(stylelint@16.6.1(typescript@5.4.5))(typescript@5.4.5)(vite@5.3.1(@types/node@20.14.6)(less@4.2.0))
@ -1597,6 +1597,10 @@ packages:
engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7}
hasBin: true
cac@6.7.14:
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
engines: {node: '>=8'}
call-bind@1.0.7:
resolution: {integrity: sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==}
engines: {node: '>= 0.4'}
@ -2096,9 +2100,6 @@ packages:
resolution: {integrity: sha512-g0QYk1dZBxGwk+Ngc+ltRH2IBp2f7zBkBMBJZCDerh6EhlhSR6+9irMCuT/09zD6qkarHUSn529sK/yL4S27mg==}
engines: {node: '>= 0.4'}
get-tsconfig@4.7.5:
resolution: {integrity: sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==}
gh-pages@6.1.1:
resolution: {integrity: sha512-upnohfjBwN5hBP9w2dPE7HO5JJTHzSGMV1JrLrHvNuqmjoYHg6TBrCcnEoorjG/e0ejbuvnwyKMdTyM40PEByw==}
engines: {node: '>=10'}
@ -2762,6 +2763,9 @@ packages:
resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
engines: {node: '>=8'}
pathe@1.1.2:
resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==}
picocolors@1.0.1:
resolution: {integrity: sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==}
@ -2969,9 +2973,6 @@ packages:
resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
engines: {node: '>=8'}
resolve-pkg-maps@1.0.0:
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
resolve@1.19.0:
resolution: {integrity: sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==}
@ -3242,11 +3243,6 @@ packages:
tslib@2.6.3:
resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==}
tsx@4.15.6:
resolution: {integrity: sha512-is0VQQlfNZRHEuSSTKA6m4xw74IU4AizmuB6lAYLRt9XtuyeQnyJYexhNZOPCB59SqC4JzmSzPnHGBXxf3k0hA==}
engines: {node: '>=18.0.0'}
hasBin: true
tty-table@4.2.3:
resolution: {integrity: sha512-Fs15mu0vGzCrj8fmJNP7Ynxt5J7praPXqFN0leZeZBXJwkMxv9cb2D454k1ltrtUSJbZ4yH4e0CynsHLxmUfFA==}
engines: {node: '>=8.0.0'}
@ -3345,6 +3341,11 @@ packages:
resolution: {integrity: sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==}
engines: {node: '>= 0.10'}
vite-node@1.6.0:
resolution: {integrity: sha512-de6HJgzC+TFzOu0NTC4RAIsyf/DY/ibWDYQUcuEA84EMHhcefTUGkjFHKKEJhQN4A+6I0u++kr3l36ZF2d7XRw==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
vite-plugin-checker@0.7.1:
resolution: {integrity: sha512-Yby+Dr6+cJlkoPagqdQQn21+ZPaYwonNSlW3VpZzoyDAxoYt7YUDhzSYrCa15iTe+X4IpiNC882a3oomxCXyTA==}
engines: {node: '>=14.16'}
@ -4720,6 +4721,8 @@ snapshots:
node-releases: 2.0.14
update-browserslist-db: 1.0.16(browserslist@4.23.1)
cac@6.7.14: {}
call-bind@1.0.7:
dependencies:
es-define-property: 1.0.0
@ -5345,10 +5348,6 @@ snapshots:
es-errors: 1.3.0
get-intrinsic: 1.2.4
get-tsconfig@4.7.5:
dependencies:
resolve-pkg-maps: 1.0.0
gh-pages@6.1.1:
dependencies:
async: 3.2.5
@ -5999,6 +5998,8 @@ snapshots:
path-type@4.0.0: {}
pathe@1.1.2: {}
picocolors@1.0.1: {}
picomatch@2.3.1: {}
@ -6202,8 +6203,6 @@ snapshots:
resolve-from@5.0.0: {}
resolve-pkg-maps@1.0.0: {}
resolve@1.19.0:
dependencies:
is-core-module: 2.13.1
@ -6545,13 +6544,6 @@ snapshots:
tslib@2.6.3: {}
tsx@4.15.6:
dependencies:
esbuild: 0.21.5
get-tsconfig: 4.7.5
optionalDependencies:
fsevents: 2.3.3
tty-table@4.2.3:
dependencies:
chalk: 4.1.2
@ -6655,6 +6647,23 @@ snapshots:
validator@13.12.0: {}
vite-node@1.6.0(@types/node@20.14.6)(less@4.2.0):
dependencies:
cac: 6.7.14
debug: 4.3.5
pathe: 1.1.2
picocolors: 1.0.1
vite: 5.3.1(@types/node@20.14.6)(less@4.2.0)
transitivePeerDependencies:
- '@types/node'
- less
- lightningcss
- sass
- stylus
- sugarss
- supports-color
- terser
vite-plugin-checker@0.7.1(eslint@8.57.0)(optionator@0.9.4)(stylelint@16.6.1(typescript@5.4.5))(typescript@5.4.5)(vite@5.3.1(@types/node@20.14.6)(less@4.2.0)):
dependencies:
'@babel/code-frame': 7.24.7

View file

@ -1,5 +1,5 @@
import ghpages from "gh-pages";
import { ANSI } from "../src/config/apps/terminal.config";
import { ANSI } from "../packages/core/src/constants";
import { BASE_URL, BUILD_DIR, COMMIT_MESSAGE, DOMAIN, REPO_URL } from "../src/config/deploy.config";
function deploy() {

View file

@ -1,9 +1,10 @@
import fs from "node:fs";
import { REPO } from "../src/config/deploy.config";
import { ANSI } from "@prozilla-os/core";
import { ANSI } from "../packages/core/src/constants";
const API_URL = "https://api.github.com/";
const TREE_PATH = "public/config/tree.json";
const TREE_DIRECTORY = "public/config";
const TREE_PATH = `${TREE_DIRECTORY}/tree.json`;
interface ReponseType {
sha: string;
@ -52,6 +53,7 @@ function fetchRepositoryTree(callback: (tree: string) => void) {
try {
fetchRepositoryTree((tree) => {
fs.mkdirSync(TREE_DIRECTORY, { recursive: true });
fs.writeFileSync(TREE_PATH, tree, { flag: "w+" });
console.log(`\n${ANSI.fg.green}✓ Generated repository tree: ${ANSI.fg.cyan + TREE_PATH + ANSI.reset}`);
});

View file

@ -1,9 +1,9 @@
import fs from "node:fs";
import { APP_DESCRIPTIONS, APP_NAMES, AppKey, APPS } from "../src/config/apps.config";
import { ANSI } from "../src/config/apps/terminal.config";
import { appsConfig } from "../src/config/apps.config";
import { ANSI } from "../packages/core/src/constants";
import { NAME, TAG_LINE } from "../src/config/branding.config";
import { WALLPAPERS } from "../src/config/desktop.config";
import { BASE_URL, BUILD_DIR, DOMAIN } from "../src/config/deploy.config";
import { desktopConfig } from "../src/config/desktop.config";
const PATHS = {
sitemapXml: BUILD_DIR + "/sitemap.xml",
@ -16,15 +16,15 @@ function generateSitemapXml() {
const date = new Date();
const lastModified = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
const images = WALLPAPERS.map((path) => `
const images = desktopConfig.wallpapers.map((path) => `
<image:image>
<image:loc>${BASE_URL.slice(0, -1) + path}</image:loc>
</image:image>`
);
const pages = Object.values(APPS).map((appId) => `
const pages = appsConfig.apps.map(({ id }) => `
<url>
<loc>${BASE_URL + appId}</loc>
<loc>${BASE_URL + id}</loc>
<lastmod>${lastModified}</lastmod>
</url>`
);
@ -89,10 +89,10 @@ function generate404Page(template: string) {
* Add an HTML file for every app page so they can be properly crawled and indexed
*/
function generateAppPages(template: string) {
for (const [key, value] of Object.entries(APPS)) {
const appId = value;
const appName = key in APP_NAMES ? APP_NAMES[key as AppKey] as string : appId;
const appDescription = Object.keys(APP_DESCRIPTIONS).includes(key) ? APP_DESCRIPTIONS[key as AppKey] as string : TAG_LINE;
for (const app of appsConfig.apps) {
const appId = app.id;
const appName = app.name;
const appDescription = app.description ?? TAG_LINE;
if (appId === "index") {
console.log("Invalid app ID found: " + appId);

View file

@ -37,17 +37,12 @@
"src/**/*",
"vite.config.ts",
"*.vite.config.ts",
// "scripts/**/*", // TO DO: uncomment this line
"scripts/**/*",
],
"exclude": [
"**/node_modules",
"**/dist",
"**/node_modules/**/*",
"**/dist/**/*",
"./.vscode",
"./.github",
],
"ts-node": {
"experimentalSpecifierResolution": "node",
"transpileOnly": true,
"esm": true,
}
}

View file

@ -14,7 +14,7 @@ const ENABLE_ALIASES = true;
* Enables importing local packages from their dist (build) directory instead of their src directory
* Useful for testing builds before publishing
*/
const USE_PACKAGE_BUILDS = false;
const USE_PACKAGE_BUILDS = true;
function generateAliases() {
if (!ENABLE_ALIASES) return {};