Skip to content

Commit

Permalink
chore: clean npm script (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
hacke2 authored Dec 11, 2024
1 parent 850d4c0 commit 5cd2379
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 174 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ yarn run start
```bash
# install dependencies
yarn
# rebuild native dependencies for electron
yarn run electron-rebuild
# rebuild native dependencies for web
yarn run web-rebuild
# build web
yarn run build-web
# start project
Expand Down
16 changes: 11 additions & 5 deletions build/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import * as path from 'node:path';
import { version as electronVersion } from 'electron/package.json'
import { nativeDeps, postInstallDeps } from './deps'
import { exec } from './util'
import { parseArgv } from '@opensumi/ide-utils/lib/argv'

const argv = parseArgv(process.argv)

export const rebuild = async (config?: { arch?: string, cwd?: string, silent?: boolean, loglevel?: string }) => {
const target = argv.target || 'electron'
const arch = config?.arch || process.arch
const cwd = config?.cwd || process.cwd()
const loglevel = config?.loglevel || 'info'
Expand All @@ -15,11 +19,13 @@ export const rebuild = async (config?: { arch?: string, cwd?: string, silent?: b
'npx',
'node-gyp',
'rebuild',
'--runtime=electron',
`--target=${electronVersion}`,
`--arch=${arch}`,
`--dist-url=https://electronjs.org/headers`,
`--loglevel=${loglevel}`
...target == 'electron' ? [
'--runtime=electron',
`--target=${electronVersion}`,
`--arch=${arch}`,
`--dist-url=https://electronjs.org/headers`,
`--loglevel=${loglevel}`
] : []
].join(' '),
null,
{
Expand Down
2 changes: 1 addition & 1 deletion build/webpack-web/webpack.browser.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import fs from 'fs'
import { createConfig, webpackDir, devServerPort } from './webpack.base.config';
import {config} from 'dotenv'
config({
path: path.join(__dirname, '../../.env')
path: path.join(__dirname, '../../.env.sample')
})

const srcDir = path.resolve('src/bootstrap-web/browser');
Expand Down
7 changes: 7 additions & 0 deletions build/webpack-web/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import browser from './webpack.browser.config';
import webview from './webpack.webview.config';
import extHost from './webpack.ext-host.config';
import workerHost from './webpack.worker-host.config'
import node from './webpack.node.config';

export default [browser, webview, extHost, workerHost, node];
2 changes: 1 addition & 1 deletion build/webpack-web/webpack.ext-host.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { asarDeps } from '../deps'
const srcDir = path.resolve('src/bootstrap-web/ext-host');
const outDir = path.join(webpackDir, 'ext-host');

module.exports = createConfig((_, argv) => ({
export default createConfig((_, argv) => ({
entry: srcDir,
output: {
filename: 'index.js',
Expand Down
2 changes: 1 addition & 1 deletion build/webpack-web/webpack.webview.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const tsConfigPath = path.join(__dirname, '../../tsconfig.json');
const distDir = path.join(webpackDir, 'webview');
const port = 8899;

module.exports = {
export default {
entry,
output: {
filename: 'webview.js',
Expand Down
2 changes: 1 addition & 1 deletion build/webpack-web/webpack.worker-host.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {webpackDir} from "./webpack.base.config";
import {createConfig} from "../webpack/webpack.base.config";
const outDir = path.join(webpackDir, 'ext-host');

module.exports = createConfig({
export default createConfig({
entry: require.resolve('@opensumi/ide-extension/lib/hosted/worker.host-preload'),
output: {
filename: 'worker-host.js',
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
"main": "out/main",
"scripts": {
"start": "electron-forge start",
"start-web": "ts-node build/webpack-web/web-start.ts",
"electron-rebuild": "node -r ts-node/register ./build/rebuild.ts",
"web-rebuild": "node -r ts-node/register ./build/rebuild.ts --target=web",
"build-web": "webpack --config ./build/webpack-web/webpack.config.ts --progress --color",
"package": "electron-forge package",
"make": "electron-forge make",
"electron-rebuild": "node -r ts-node/register ./build/rebuild.ts",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"release": "standard-version",
"release:minor": "npm run release -- --release-as minor",
"build-web": "webpack --config ./build/webpack-web/webpack.browser.config.ts --progress --color && webpack --config ./build/webpack-web/webpack.webview.config.ts --progress --color && webpack --config ./build/webpack-web/webpack.ext-host.config.ts --progress --color && webpack --config ./build/webpack-web/webpack.worker-host.config.ts --progress --color && webpack --config ./build/webpack-web/webpack.node.config.ts --progress --color",
"start-web": "ts-node build/webpack-web/web-start.ts"
"release:minor": "npm run release -- --release-as minor"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap-web/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import {config} from 'dotenv'
import path from "path";

config({
path: path.resolve(__dirname, '../../../.env')
path: path.resolve(__dirname, '../../../..env.sample')
})
2 changes: 1 addition & 1 deletion src/logger/node/log-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ export class LogServiceManager extends AbstractLogServiceManager {
}

getLogFolder(): string {
return path.join(process.env.IDE_LOG_HOME!, `window${process.env.CODE_WINDOW_CLIENT_ID!.slice('CODE_WINDOW_CLIENT_ID:'.length)}`)
return path.join(process.env.IDE_LOG_HOME || '', `window${process.env.CODE_WINDOW_CLIENT_ID?.slice('CODE_WINDOW_CLIENT_ID:'?.length)}`)
}
}
Loading

0 comments on commit 5cd2379

Please sign in to comment.