Skip to content

Commit 8c30468

Browse files
lbogdanCompuIves
authored andcommitted
Scripts spring cleanup (codesandbox#780)
* Updated package.json scripts for a better development experience and faster builds. * Upgraded uglifyjs-webpack-plugin to 1.2.5. * Removed unneeded babili-webpack-plugin. * Added / updated details about the development environment. * Added info on how to login on dev. * CircleCI: use 'build:deps' to build dependencies. * CircleCI: removed unneeded BrowserStack setup step. * CircleCI: fixed build error when unavailable docker credentials. * Renamed "dev[:smth]" scripts to "start[:smth]". * CircleCI: Re-added BrowserStack, but only run it when credentials are set. * CircleCI: moved Dockerfile from config to a file. * Dummy commit
1 parent b559be4 commit 8c30468

File tree

10 files changed

+46
-254
lines changed

10 files changed

+46
-254
lines changed

.circleci/config.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- standalone-packages/codesandbox-browserfs/node_modules
3737
- run:
3838
name: Build
39-
command: yarn build:dependents
39+
command: yarn build:deps
4040
- save_cache:
4141
key: v8-repo-{{ .Environment.CIRCLE_SHA1 }}
4242
paths:
@@ -80,7 +80,7 @@ jobs:
8080
background: true
8181
- run:
8282
name: Setup BrowserStack local environment
83-
command: ./packages/app/integration-tests/BrowserStackLocal --key $BROWSER_STACK_KEY
83+
command: "[ -n \"$BROWSER_STACK_KEY\" ] && ./packages/app/integration-tests/BrowserStackLocal --key $BROWSER_STACK_KEY || true"
8484
background: true
8585
- run:
8686
name: Test Integrations
@@ -127,21 +127,13 @@ jobs:
127127
key: v8-prod-build-cache-{{ .Environment.CIRCLE_BRANCH }}-{{ .Environment.CIRCLE_SHA1 }}
128128
- run:
129129
name: Docker Sign In
130-
command: "if [ -n $DOCKER_USER ]; then echo $DOCKER_PWD | docker login -u $DOCKER_USER --password-stdin; else exit 0; fi"
131-
- run:
132-
name: Create Dockerfile
133-
command: |
134-
cat > Dockerfile <<EOF
135-
FROM busybox:1.28.1
136-
WORKDIR /codesandbox
137-
COPY www /codesandbox
138-
EOF
130+
command: "[ -n \"$DOCKER_USER\" ] && echo $DOCKER_PWD | docker login -u $DOCKER_USER --password-stdin || true"
139131
- run:
140132
name: Create Image
141-
command: docker build -t codesandbox/client:${CIRCLE_SHA1:0:7} .
133+
command: "[ -n \"$DOCKER_USER\" ] && docker build -t codesandbox/client:${CIRCLE_SHA1:0:7} . || true"
142134
- deploy:
143135
name: Push Image
144-
command: "if [ -n $DOCKER_USER ]; then docker push codesandbox/client:${CIRCLE_SHA1:0:7}; else exit 0; fi"
136+
command: "[ -n \"$DOCKER_USER\" ] && docker push codesandbox/client:${CIRCLE_SHA1:0:7} || true"
145137

146138
workflows:
147139
version: 2

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ The CodeSandbox client is currently divided in to 5 parts. We use `lerna` to sha
66

77
- `app`: The editor, the search, profile page, the embed and the sandbox.
88
- `homepage`: The Gatsby website of the homepage.
9-
- `codesandbox-api`: The npm package that's responsible for communication between the sandbox and the editor.
109
- `common`: All common parts between these packages, reusable JS.
10+
- `codesandbox-api`: The npm package that's responsible for communication between the sandbox and the editor.
11+
- `codesandbox-browserfs`: An in-browser file system that emulates the Node JS file system API and supports storing and retrieving files from various backends. Forked from [https://github.com/jvilk/BrowserFS](https://github.com/jvilk/BrowserFS), with an additional [CodeSandbox backend](https://github.com/CompuIves/codesandbox-client/blob/master/standalone-packages/codesandbox-browserfs/src/backend/CodeSandboxFS.ts).
1112

12-
This version of CodeSandbox is using the production server as source of truth, this is specified by the environment variable `LOCAL_SERVER`. It's not yet possible to sign in using this version, I haven't figured out how to handle this yet.
13+
This version of CodeSandbox is using the production server as source of truth, this is specified by the environment variable `LOCAL_SERVER`. If you're working on a feature that needs you to be logged in, you can login on [https://codesandbox.io/](https://codesandbox.io/) and copy the contents of the `jwt` local storage key over to your development environment on [http://localhost:3000/](http://localhost:3000/). **Be very careful with how you handle the token**, as anyone who knows it can login as you and have read/write access to all your CodeSandbox content!
1314

1415
**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
1516

@@ -28,6 +29,9 @@ To install the project you need to have `yarn` and `node`
2829
```
2930
2. `yarn` to install dependencies
3031
3. `yarn start` to start the app
32+
* this builds the dependencies (`codesandbox-api` and `codesandbox-browserfs`) and runs the `app` development environment, available on [http://localhost:3000/s/new](http://localhost:3000/s/new)
33+
* on subsequent runs you can also bypass dependencies building and use `yarn start:fast`
34+
* if you want to work on the homepage, start it with `yarn start:home`, it will be available on [http://localhost:8000/](http://localhost:8000/)
3135

3236
> Tip: Keep your `master` branch pointing at the original repository and make
3337
> pull requests from branches on your fork. To do this, run:

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM busybox:1.28.1
2+
3+
WORKDIR /codesandbox
4+
5+
COPY www /codesandbox

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
"license": "MIT",
55
"private": true,
66
"scripts": {
7-
"build": "yarn build:dependents && yarn build:prod",
7+
"build": "yarn build:deps && yarn build:prod",
88
"build:prod": "lerna run build --scope app --scope homepage --parallel && gulp",
9-
"build:dependents": "lerna run build --scope codesandbox-api --scope common --scope codesandbox-browserfs --stream && lerna run build --scope smooshpack --stream && lerna run build --scope react-smooshpack --stream",
10-
"start": "lerna run build --scope codesandbox-browserfs --stream && lerna run start --parallel",
9+
"build:deps": "lerna run build:dev --scope codesandbox-{api,browserfs}",
10+
"start": "yarn build:deps && lerna run start --scope app --stream",
1111
"start:fast": "lerna run start --scope app --stream",
12+
"start:home": "lerna run start --scope homepage --stream",
1213
"start:test": "lerna run start:test --scope app --stream",
1314
"start:dev_api": "lerna run start --parallel --ignore app & lerna run start:dev_api --scope app --stream",
1415
"test": "lerna run test --ignore codesandbox-browserfs",

packages/app/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start:sandbox": "cross-env SANDBOX_ONLY=true node scripts/start.js",
99
"start:dev_api": "node scripts/start.js",
1010
"start:test": "cross-env LOCAL_SERVER=1 NODE_ENV=test SANDBOX_ONLY=true node scripts/start.js",
11-
"build": "NODE_ENV=production node scripts/build.js",
11+
"build": "cross-env NODE_ENV=production node scripts/build.js",
1212
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js",
1313
"test": "jest --env=jsdom",
1414
"test:watch": "jest --watch --env=jsdom",
@@ -36,7 +36,6 @@
3636
"babel-plugin-transform-runtime": "^6.23.0",
3737
"babel-preset-env": "^1.6.0",
3838
"babel-preset-react": "^6.24.1",
39-
"babili-webpack-plugin": "^0.1.1",
4039
"buffer-loader": "^0.0.1",
4140
"case-sensitive-paths-webpack-plugin": "^2.0.0",
4241
"chalk": "1.1.3",
@@ -83,7 +82,7 @@
8382
"style-loader": "^0.18.2",
8483
"sw-precache-webpack-plugin": "^0.11.4",
8584
"typescript": "^2.4.2",
86-
"uglifyjs-webpack-plugin": "^1.0.1",
85+
"uglifyjs-webpack-plugin": "^1.2.5",
8786
"url-loader": "^0.5.9",
8887
"webpack": "^3.5.4",
8988
"webpack-bundle-analyzer": "^2.9.0",
@@ -106,8 +105,8 @@
106105
"babel-plugin-syntax-jsx": "^6.18.0",
107106
"babel-plugin-system-import": "^1.1.5",
108107
"babel-plugin-system-import-transformer": "3.1.0",
109-
"babel-plugin-transform-cx-jsx": "^17.12.0",
110108
"babel-plugin-transform-async-to-generator": "^6.24.1",
109+
"babel-plugin-transform-cx-jsx": "^17.12.0",
111110
"babel-plugin-transform-decorators-legacy": "^1.3.4",
112111
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
113112
"babel-plugin-transform-vue-jsx": "^3.5.0",

packages/codesandbox-api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"prebuild": "rimraf dist",
2424
"build:clean": "tsc && rollup -c",
2525
"build": "tsc && rollup -c && rimraf compiled && typedoc --out dist/docs --target es6 --theme minimal src",
26+
"build:dev": "tsc && rollup -c",
2627
"start": "nodemon --watch \"src/**/*.ts\" -e ts --exec \"npm run build:clean\"",
2728
"test": "echo TODO",
2829
"test:watch": "jest --watch",

packages/codesandbox-api/rollup.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ export default {
2626
// Resolve source maps to the original source
2727
sourceMaps(),
2828
],
29+
onwarn: function(warning) {
30+
if (warning.code !== 'THIS_IS_UNDEFINED') {
31+
console.warn(warning);
32+
}
33+
},
2934
};

packages/homepage/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
"license": "MIT",
3838
"main": "n/a",
3939
"scripts": {
40-
"patch": "sed -i -e 's/if(c\\.initial) return;/if(!c||c.initial) return;/g' ../../node_modules/extract-text-webpack-plugin/index.js",
41-
"build": "yarn patch && gatsby build && yarn remove-styles",
40+
"build": "gatsby build && yarn remove-styles",
4241
"remove-styles": "rimraf public/styles.css",
4342
"start": "gatsby develop",
4443
"lint": "echo TODO && exit 0",

standalone-packages/codesandbox-browserfs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"build:webpack-release": "webpack -p --config src/webpack.config.js",
8585
"watch:webpack-release": "webpack -w -p --config src/webpack.config.js",
8686
"build:all": "npm-run-all --parallel build:tsc build:scripts --sequential build:rollup --parallel build:webpack build:webpack-release",
87+
"build:dev": "npm-run-all --parallel build:tsc build:scripts --sequential build:rollup --parallel build:webpack build:webpack-release --sequential script:make_dist",
8788
"start": "npm-run-all build --parallel watch:tsc watch:scripts watch:rollup watch:webpack watch:webpack-release",
8889
"test:build:tsc": "tsc -p test",
8990
"test:watch:tsc": "tsc --watch -p test",

0 commit comments

Comments
 (0)