5 changed files with 1860 additions and 2300 deletions
@ -0,0 +1,68 @@ |
|||
// const esbuild = require('esbuild');
|
|||
// import esbuild from 'esbuild';
|
|||
// import fs from 'fs';
|
|||
// import path from 'path';
|
|||
const esbuild = require('esbuild'); |
|||
const fs = require('fs'); |
|||
const path = require('path') |
|||
const targetDir = 'dist'; |
|||
|
|||
async function build() |
|||
{ |
|||
const result = await esbuild.build({ |
|||
entryPoints: ['src/app.ts'], |
|||
bundle: true, |
|||
platform: 'node', |
|||
sourcemap: 'external', |
|||
outfile: `${targetDir}/app.js`, |
|||
external: ['punycode'] |
|||
}).catch(() => process.exit(1)) |
|||
|
|||
copyFiles(); |
|||
} |
|||
|
|||
function copyFiles() |
|||
{ |
|||
const sdk = JSON.parse(fs.readFileSync(path.join(process.cwd(), './src/com/7zcloud/', './config/sdk.json'), {encoding: 'utf-8'})) |
|||
copyConfigs(sdk); |
|||
copySdks(sdk); |
|||
} |
|||
|
|||
function copyConfigs(sdk) |
|||
{ |
|||
const len = sdk.sdkpath.length; |
|||
const targetPaths = []; |
|||
for(let i = 0;i < len;i ++){ |
|||
let sdkPath = sdk.sdkpath[i]; |
|||
sdkPath = sdkPath.substring(sdkPath.lastIndexOf('/')); |
|||
targetPaths.push(`./sdk${sdkPath}`) |
|||
} |
|||
const targetSdk = { |
|||
sdkpath: targetPaths, |
|||
isDev: false |
|||
} |
|||
const dirPath = mkdirSync('config') |
|||
fs.writeFileSync(path.join(dirPath, `/sdk.json`), JSON.stringify(targetSdk, null, 4)); |
|||
} |
|||
|
|||
function copySdks(sdk) |
|||
{ |
|||
const targetDir = mkdirSync('sdk') |
|||
for(let i = 0;i < sdk.sdkpath.length;i ++) |
|||
{ |
|||
let sdkPath = sdk.sdkpath[i]; |
|||
sdkPath = sdkPath.substring(sdkPath.lastIndexOf('/')); |
|||
fs.copyFileSync(path.join(process.cwd(), sdk.sdkpath[i]), `${targetDir}${sdkPath}`) |
|||
} |
|||
} |
|||
|
|||
function mkdirSync(dir) |
|||
{ |
|||
const dirPath = path.join(process.cwd(), `${targetDir}/${dir}`); |
|||
if(fs.existsSync(dirPath) === false){ |
|||
fs.mkdirSync(dirPath); |
|||
} |
|||
return dirPath; |
|||
} |
|||
|
|||
build(); |
@ -1,19 +1,19 @@ |
|||
{ |
|||
"restartable": "rs", |
|||
"ignore": [ |
|||
".git", |
|||
".svn", |
|||
"node_modules/**/node_modules" |
|||
], |
|||
"verbose": true, |
|||
"execMap": { |
|||
"js": "node --harmony" |
|||
}, |
|||
"watch": [ |
|||
|
|||
], |
|||
"env": { |
|||
"NODE_ENV": "dev" |
|||
}, |
|||
"ext": "js" |
|||
{ |
|||
"restartable": "rs", |
|||
"ignore": [ |
|||
".git", |
|||
".svn", |
|||
"node_modules/**/node_modules" |
|||
], |
|||
"verbose": true, |
|||
"execMap": { |
|||
"js": "node --harmony" |
|||
}, |
|||
"watch": [ |
|||
|
|||
], |
|||
"env": { |
|||
"NODE_ENV": "dev" |
|||
}, |
|||
"ext": "js" |
|||
} |
File diff suppressed because it is too large
Loading…
Reference in new issue