From df6fc44d9a65743a678cdf38ddacd5a1178857ee Mon Sep 17 00:00:00 2001 From: baozhoutao Date: Sat, 6 Nov 2021 18:18:08 +0800 Subject: [PATCH] =?UTF-8?q?add=20scripts=20=EF=BC=9A=20start-dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用于开发测试,防止template project被改坏 --- .gitignore | 2 ++ .scripts/create_dev_project.js | 45 ++++++++++++++++++++++++++++++++++ package.json | 4 ++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .scripts/create_dev_project.js diff --git a/.gitignore b/.gitignore index 9b2bda4df9..a70316a750 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,5 @@ packages/cli/dist/** docker-volumes packages/node-red-app-template/yarn.lock + +steedos-projects/project-dev/** \ No newline at end of file diff --git a/.scripts/create_dev_project.js b/.scripts/create_dev_project.js new file mode 100644 index 0000000000..af235f149c --- /dev/null +++ b/.scripts/create_dev_project.js @@ -0,0 +1,45 @@ +const cpy = require('cpy'); +const path = require('path'); +const fs = require('fs'); + +if (fs.existsSync(path.join(process.cwd(), 'steedos-projects', 'project-dev'))) { + return; +} + +cpy([ + '**', + '.steedos/**', + '!.steedos/node_modules/**', + '.vscode/**', + '!**/node_modules/**', + '!logs/**', + '.env.local', + '!steedos-config-k8s.yml', + '!storage/**', + '.gitignore', + '!init_home.sh', + '.env', +], '../../steedos-projects/project-dev', { + parents: true, + flat: false, + cwd: path.join(process.cwd(), 'steedos-projects', 'project-template'), + rename: (name) => { + switch (name) { + // case '.env': + // return 'env' + // case '.gitignore': { + // return 'gitignore' + // } + // case 'package.json': { + // return '_package.json' + // } + default: { + return name + } + } + } +}).then(() => { + console.log(`Create a development project: steedos-projects/project-dev`); +}).catch((result) => { + console.log(`error`, result); +}) \ No newline at end of file diff --git a/package.json b/package.json index ebcda08939..79326b74f4 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,9 @@ "update-yarn": "curl --compressed -o- -L https://yarnpkg.com/install.sh | bash", "sync-to-taobao": "node .scripts/sync_to_taobao.js", "build_image": "node build_image.js", - "build_creator": "cd creator && yarn run build" + "build_creator": "cd creator && yarn run build", + "create_dev_project": "node .scripts/create_dev_project.js", + "start-dev": "yarn create_dev_project && cd steedos-projects && cd project-dev && yarn start" }, "resolutions": { "**/lodash": "^4.17.15",