Skip to content

Commit

Permalink
Command "build:with-relative-imports-transform-and-run"
Browse files Browse the repository at this point in the history
  • Loading branch information
d9k committed Dec 29, 2023
1 parent 2efaa14 commit 0fdf40e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
9 changes: 7 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"dev": "deno run --no-npm -A --no-check --watch ./server.tsx",
"test": "deno test --no-npm --allow-all",
"build": "deno run --no-npm -A ./build.ts",
"build:with-relative-imports-transform-and-run": "deno run --no-npm -A ./script/build-with-relative-imports-transform-and-run.ts",
"prebuild:copy-and-transform-imports-to-relative": "deno run --no-npm --allow-env --allow-read --allow-write ./script/copy-and-transform-imports-to-relative.ts",
"start": "ULTRA_MODE=production deno run --no-npm -A --no-remote ./server.js",
"storybook": "pnpm run storybook",
Expand Down Expand Up @@ -40,13 +41,17 @@
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"]
},
"fmt": {
"exclude": [".ultra"],
"exclude": [".ultra", ".project-copy-with-imports-transformed-to-relative"],
"indentWidth": 2,
"proseWrap": "preserve",
"singleQuote": true
},
"lint": {
"exclude": [".ultra", "script-node"]
"exclude": [
".ultra",
".project-copy-with-imports-transformed-to-relative",
"script-node"
]
},
"importMap": "./importMap.json",
"nodeModulesDir": false
Expand Down
32 changes: 32 additions & 0 deletions script/build-with-relative-imports-transform-and-run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as dotenv from 'dotenv';

import { envValueRequire } from '/~/shared/lib/deno/env.ts';

import { runCommandWithPipedOutput } from '/~/shared/lib/deno/run.ts';
import * as path from 'std/path';

await dotenv.load({ export: true });

const PROJECT_COPY_WITH_IMPORTS_TRANSFORMED_TO_RELATIVE_PATH = envValueRequire(
'PROJECT_COPY_WITH_IMPORTS_TRANSFORMED_TO_RELATIVE_PATH',
);

const buildOutput = path.join(
PROJECT_COPY_WITH_IMPORTS_TRANSFORMED_TO_RELATIVE_PATH,
'.ultra',
);

await runCommandWithPipedOutput('deno', [
'task',
'prebuild:copy-and-transform-imports-to-relative',
]);

await runCommandWithPipedOutput('deno', [
'task',
'build',
], { cwd: PROJECT_COPY_WITH_IMPORTS_TRANSFORMED_TO_RELATIVE_PATH });

await runCommandWithPipedOutput('deno', [
'task',
'start',
], { cwd: buildOutput });

0 comments on commit 0fdf40e

Please sign in to comment.