From 1ade345ff67cf4ff380b408c0d2df3ef8e127c40 Mon Sep 17 00:00:00 2001 From: dobromirts Date: Wed, 7 Jun 2023 13:28:07 +0300 Subject: [PATCH] Add codesandbox dockerfile config --- src/generators/SharedAssetsGenerator.ts | 3 +++ src/templates/Dockerfile.template | 1 + src/templates/angular.json.template | 5 ++++- src/templates/tasks.json.template | 28 +++++++++---------------- 4 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 src/templates/Dockerfile.template diff --git a/src/generators/SharedAssetsGenerator.ts b/src/generators/SharedAssetsGenerator.ts index 4aaa8a3..ffd1796 100644 --- a/src/generators/SharedAssetsGenerator.ts +++ b/src/generators/SharedAssetsGenerator.ts @@ -15,6 +15,7 @@ const ENVIRONMENT_FILE_PATH = path.join(__dirname, "../templates/environment.ts. const ENVIRONMENT_PROD_FILE_PATH = path.join(__dirname, "../templates/environment.prod.ts.template"); const STACKBLITZ_CONFIG_FILE_PATH = path.join(__dirname, "../templates/stackblitzrc.template"); const CODESANDBOX_TASKS_FILE_PATH = path.join(__dirname, "../templates/tasks.json.template"); +const CODESANDBOX_DOCKER_FILE_PATH = path.join(__dirname, "../templates/Dockerfile.template"); export class SharedAssetsGenerator { constructor(private options: ILiveEditingOptions) { @@ -49,6 +50,7 @@ export class SharedAssetsGenerator { let tsConfigAppFile = fs.readFileSync(TS_APP_CONFIG_FILE_PATH, "utf8"); let stackblitzConfigFile = fs.readFileSync(STACKBLITZ_CONFIG_FILE_PATH, "utf8"); let codesandboxTasks= fs.readFileSync(CODESANDBOX_TASKS_FILE_PATH, "utf8"); + let codesandboxDocker= fs.readFileSync(CODESANDBOX_DOCKER_FILE_PATH, "utf8"); if(this.options.additionalSharedStyles?.length) { this.options.additionalSharedStyles.forEach(fileName => { @@ -61,6 +63,7 @@ export class SharedAssetsGenerator { files.push(new LiveEditingFile("tsconfig.app.json", tsConfigAppFile)); files.push(new LiveEditingFile(".stackblitzrc", stackblitzConfigFile)); files.push(new LiveEditingFile(".codesandbox/tasks.json", codesandboxTasks)); + files.push(new LiveEditingFile(".codesandbox/Dockerfile", codesandboxDocker)); files.push(new LiveEditingFile(SAMPLE_ENVIRONMENTS_FOLDER + "environment.ts", environmentFile)); files.push(new LiveEditingFile(SAMPLE_ENVIRONMENTS_FOLDER + "environment.prod.ts", environmentProdFile)); } diff --git a/src/templates/Dockerfile.template b/src/templates/Dockerfile.template new file mode 100644 index 0000000..adf04bd --- /dev/null +++ b/src/templates/Dockerfile.template @@ -0,0 +1 @@ +FROM node:18 \ No newline at end of file diff --git a/src/templates/angular.json.template b/src/templates/angular.json.template index 0f3054c..f2ace89 100644 --- a/src/templates/angular.json.template +++ b/src/templates/angular.json.template @@ -103,5 +103,8 @@ } } }, - "defaultProject": "example-app" + "defaultProject": "example-app", + "cli": { + "analytics": false + } } diff --git a/src/templates/tasks.json.template b/src/templates/tasks.json.template index a0df3e3..8d92a54 100644 --- a/src/templates/tasks.json.template +++ b/src/templates/tasks.json.template @@ -3,23 +3,15 @@ "setupTasks": [ { "name": "Install Dependencies", - "command": "npm i --legacy-peer-deps" - }, - { - "name": "Install Angular Cli", - "command": "npm i @angular/cli --force" - }, - { - "name": "Start Sample", - "command": "ng serve --disable-host-check" + "command": "yarn install" } ], - - // These tasks can be run from CodeSandbox. Running one will open a log in the app. - "tasks": { - "ng serve --disable-host-check": { - "name": "ng serve --disable-host-check", - "command": "ng serve --disable-host-check" - }, - } -} + // These tasks can be run from CodeSandbox. Running one will open a log in the app. + "tasks": { + "node node_modules/@angular/cli/bin/ng serve -o --disable-host-check": { + "name": "Start Project", + "command": "node node_modules/@angular/cli/bin/ng serve -o --disable-host-check", + "runAtStart": true + } + } +} \ No newline at end of file