Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
giniedp committed Aug 5, 2023
1 parent a4daaf7 commit 9b4948f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dev:server": "ng run nw-buddy:serve-ssr",
"dev:wrangler": "wrangler pages dev dist/web-cloud",
"dev:tools": "yarn build:tools -w",
"build:cloudflare": "yarn nw-cdn download && yarn nw-build -o dist/public",
"build:cloudflare": "yarn nw-build -o dist/public && yarn nw-cdn download -o dist/public/nw-data",
"build:electron": "yarn electron:tsc && yarn build:web-electron && yarn electron:builder",
"build:docker": "yarn build:web && yarn build:server && yarn docker:build",
"build:tools": "tsc -p ./tools/tsconfig.json",
Expand Down
21 changes: 12 additions & 9 deletions tools/nw-build.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { program } from 'commander'
import { BRANCH_NAME, NW_USE_PTR } from '../env'
import { BRANCH_NAME, NW_USE_PTR, nwData } from '../env'
import { spawn } from './utils/spawn'

import { mkdir } from './utils/file-utils'
import * as path from 'path'
program
.requiredOption('-o, --output <path>', 'output directory')
.option('-m, --module <module>', 'The module to build', BRANCH_NAME === 'main' ? 'storybook' : 'website')
.option('--ptr', 'PTR mode', NW_USE_PTR)
.action(async () => {
const options =
program.opts<{
output: string
ptr: boolean
module: string
}>()
const options = program.opts<{
output: string
ptr: boolean
module: string
}>()

const yarn = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn'
const spawnOptions = { stdio: 'inherit' } as const
await spawn(yarn, ['nw-cdn', 'download'], spawnOptions)

// ensure nw-data directory exists so storybook does not fail.
// we build storybook with empty nw-data dir, do avoid high memory error during cloudflare pipeline
await mkdir(nwData.distDir(options.ptr), { recursive: true })
if (options.module === 'storybook') {
await spawn(yarn, ['storybook:build', '--output-dir', options.output], spawnOptions)
} else {
Expand Down

0 comments on commit 9b4948f

Please sign in to comment.