Skip to content

Commit

Permalink
Refactor npm scripts, clean up unused ones (#1392)
Browse files Browse the repository at this point in the history
Co-Authored-By: Artur Paikin <artur@arturpaikin.com>
  • Loading branch information
kvz and arturi committed Mar 29, 2019
1 parent 3b09b9f commit 5f4f1cf
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 218 deletions.
12 changes: 6 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Unit tests are using Jest and can be run with:
npm run test:unit
```

For acceptance (or end-to-end) tests, we use [Webdriverio](http://webdriver.io). For it to run locally, you need to install a Selenium standalone server. Just follow [the guide](http://webdriver.io/guide.html) to do so. You can also install a Selenium standalone server from NPM:
For end-to-end tests, we use [Webdriverio](http://webdriver.io). For it to run locally, you need to install a Selenium standalone server. Just follow [the guide](http://webdriver.io/guide.html) to do so. You can also install a Selenium standalone server from NPM:

```bash
npm install selenium-standalone -g
Expand All @@ -39,27 +39,27 @@ selenium-standalone start
After you have installed and launched the selenium standalone server, run:

```bash
npm run test:acceptance:local
npm run test:endtoend:local
```

By default, `test:acceptance:local` uses Firefox. You can use a different browser, like Chrome, by passing the `-b` flag:
By default, `test:endtoend:local` uses Firefox. You can use a different browser, like Chrome, by passing the `-b` flag:

```bash
npm run test:acceptance:local -- -b chrome
npm run test:endtoend:local -- -b chrome
```

> Note: The `--` is important, it tells npm that the remaining arguments should be interpreted by the script itself, not by npm.
You can run in multiple browsers by passing multiple `-b` flags:

```bash
npm run test:acceptance:local -- -b chrome -b firefox
npm run test:endtoend:local -- -b chrome -b firefox
```

When trying to get a specific integration test to pass, it's not that helpful to continuously run _all_ tests. You can use the `--suite` flag to run tests from a single `./test/endtoend` folder. For example, `--suite thumbnails` will only run the tests from `./test/endtoend/thumbnails`. Of course, it can also be combined with one or more `-b` flags.

```bash
npm run test:acceptance:local -- -b chrome --suite thumbnails
npm run test:endtoend:local -- -b chrome --suite thumbnails
```

These tests are also run automatically on Travis builds with [SauceLabs](https://saucelabs.com/) cloud service using different OSes.
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ install:
script:
- npm run build
- npm run test
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test:acceptance; fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test:endtoend; fi
- npm run uploadcdn
cache:
apt: true
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ What we need to do to release Uppy 1.0

- [ ] chore: hunt down all `@TODO`s and either fix, or remove, or move to github issues/changelog backlog
- [ ] chore: remove dead code/commented blocks
- [ ] chore: remove the not-working npm scripts
- [ ] chore: rewrite all code based on prettier+standardjs.com
- [ ] locale: update the locales of languages that we know ourselves. leave rest to community
- [ ] locale: cdn (just in folder like Robodog, will attach to global) / for module to all languages in one big `@uppy/locales`
Expand All @@ -109,7 +108,8 @@ What we need to do to release Uppy 1.0
- [ ] transloadit: add error reporting, see https://github.com/transloadit/jquery-sdk/blob/891e99b08dd8142d8d8adc0553e6511967635ad7/js/lib/Modal.js#L122-L136 (@goto-bus-stop, @arturi)
- [ ] transloadit: should adhere cancel event and abort assembly (@arturi, @goto-bus-stop)
- [ ] dashboard: optional alert `onbeforeunload` while upload is in progress, safeguarding from accidentaly navigating away from a page with an ongoing upload

- [x] chore: remove the not-working npm scripts (@kvz, @arturi)
- [x] build: (BREAKING) `npm run dev` no longer starts Companion by default, use `npm run dev:with-companion` for that (@arturi)
- [x] core: uppy should not crash or be slow for many files. Specifically: be able to drop 5 files (or 7mb) without the upload button to take 2 seconds to appear
- [x] uppy-server: bump minor and deprecate that on npm in favour of @uppy/companion (@arturi)
- [x] dashboard: implement Alex and Artur’s Dashboard redesign (@arturi)
Expand Down
100 changes: 0 additions & 100 deletions bin/bootandkill-servers

This file was deleted.

File renamed without changes.
Empty file modified bin/companion
100644 → 100755
Empty file.
42 changes: 0 additions & 42 deletions bin/gzip.js

This file was deleted.

2 changes: 1 addition & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ git add README.md
# Add readme file to the main `uppy` package.
cp README.md packages/uppy/README.md

npm run clean
npm run build:clean
FRESH=1 npm run build

git commit --allow-empty -m "Release"
Expand Down
2 changes: 1 addition & 1 deletion examples/dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"watchify": "^3.11.0"
},
"scripts": {
"watch": "watchify -t babelify -t aliasify main.js -o bundle.js -vd"
"watch:sandbox": "watchify -t babelify -t aliasify main.js -o bundle.js -vd"
},
"aliasify": {
"aliases": {
Expand Down
58 changes: 28 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,58 +81,56 @@
},
"scripts": {
"bootstrap": "lerna bootstrap",
"build:bundle": "node ./bin/build-js.js",
"build:bundle": "node ./bin/build-bundle.js",
"build:clean": "rm -rf packages/*/lib packages/@uppy/*/lib packages/*/dist packages/@uppy/*/dist",
"build:companion": "cd ./packages/@uppy/companion && npm run build",
"build:css": "node ./bin/build-css.js",
"build:gzip": "node ./bin/gzip.js",
"build:js": "npm-run-all build:lib build:bundle",
"build:lib": "node ./bin/build-lib.js",
"build": "npm-run-all --parallel build:js build:css build:companion --serial build:gzip size",
"clean": "rm -rf packages/*/lib packages/@uppy/*/lib packages/*/dist packages/@uppy/*/dist",
"contributors:save": "replace-x -m '<!--contributors-->[\\s\\S]+<!--/contributors-->' \"<!--contributors-->\n## Contributors\n\n$(npm run --silent contributors)\n<!--/contributors-->\" README.md",
"contributors": "githubcontrib --owner transloadit --repo uppy --cols 6 $([ \"${GITHUB_TOKEN:-}\" == \"\" ] && echo \"\" || echo \"--authToken ${GITHUB_TOKEN}\") --showlogin true --sortOrder desc",
"build": "npm-run-all --parallel build:js build:css build:companion --serial size",
"contributors:fetch": "githubcontrib --owner transloadit --repo uppy --cols 6 $([ \"${GITHUB_TOKEN:-}\" == \"\" ] && echo \"\" || echo \"--authToken ${GITHUB_TOKEN}\") --showlogin true --sortOrder desc",
"contributors:save": "replace-x -m '<!--contributors-->[\\s\\S]+<!--/contributors-->' \"<!--contributors-->\n## Contributors\n\n$(npm run --silent contributors:fetch)\n<!--/contributors-->\" README.md",
"dev:browsersync": "browser-sync start --no-open --no-ghost-mode false --server examples/dev --port 3452 --serveStatic packages/uppy/dist --files \"examples/dev/bundle.js, packages/uppy/dist/uppy.min.css, packages/uppy/lib/**/*\"",
"dev:js": "cd examples/dev && npm run watch",
"dev:no-companion": "npm-run-all --parallel dev:js watch:css watch:js:lib dev:browsersync",
"dev": "npm-run-all --parallel start:companion dev:js watch:css watch:js:lib dev:browsersync",
"dev:watch-sandbox": "cd examples/dev && npm run watch:sandbox",
"dev:with-companion": "npm-run-all --parallel start:companion dev:watch-sandbox watch dev:browsersync",
"dev": "npm-run-all --parallel dev:watch-sandbox watch dev:browsersync",
"lint:fix": "npm run lint -- --fix",
"lint:staged": "lint-staged",
"lint": "eslint . --cache",
"release": "./bin/release",
"size": "echo 'JS Bundle mingz:' && cat ./packages/uppy/dist/uppy.min.js | gzip | wc -c && echo 'CSS Bundle mingz:' && cat ./packages/uppy/dist/uppy.min.css | gzip | wc -c",
"start:companion": "sh ./bin/companion",
"start": "npm-run-all --parallel watch start:companion web:preview",
"test:acceptance:local": "npm run test:build && wdio test/endtoend/wdio.local.conf.js",
"test:acceptance": "npm run test:prepare-ci && wdio test/endtoend/wdio.remote.conf.js",
"test:build-ci": "./bin/endtoend-build-ci",
"test:build": "./bin/endtoend-build",
"start:companion": "./bin/companion",
"start": "npm-run-all --parallel watch start:companion web:start",
"test:companion": "cd ./packages/@uppy/companion && npm run test",
"test:prepare-ci": "npm-run-all --parallel --race test:registry test:build-ci",
"test:registry": "verdaccio --listen 4002 --config test/endtoend/verdaccio.yaml",
"test:endtoend:build-ci": "./bin/endtoend-build-ci",
"test:endtoend:build": "./bin/endtoend-build",
"test:endtoend:local": "npm run test:endtoend:build && wdio test/endtoend/wdio.local.conf.js",
"test:endtoend:prepare-ci": "npm-run-all --parallel --race test:endtoend:registry test:endtoend:build-ci",
"test:endtoend:registry": "verdaccio --listen 4002 --config test/endtoend/verdaccio.yaml",
"test:endtoend": "npm run test:endtoend:prepare-ci && wdio test/endtoend/wdio.remote.conf.js",
"test:type": "tsc -p .",
"test:unit": "npm run build:lib && jest",
"test:watch": "jest --watch",
"test": "npm-run-all lint test:unit test:type test:companion",
"travis:deletecache": "travis cache --delete",
"uploadcdn": "bin/upload-to-cdn.sh",
"version": "./bin/sync-version-numbers",
"watch:css": "onchange 'packages/**/*.scss' --initial --verbose -- npm run build:css",
"watch:js:bundle": "onchange 'packages/{@uppy/,}*/src/**/*.js' --initial --verbose -- npm run build:bundle",
"watch:js:lib": "onchange 'packages/{@uppy/,}*/src/**/*.js' --initial --verbose -- npm run build:lib",
"watch:js": "onchange 'packages/{@uppy/,}*/src/**/*.js' --initial --verbose -- npm run build:bundle",
"watch": "npm-run-all --parallel watch:js watch:css",
"web:build": "npm-run-all web:inject web:generate web:examples",
"web:bundle:update:watch": "onchange 'packages/uppy/dist/**/*.css' 'packages/uppy/dist/**/*.js' --initial --verbose -- npm run web:inject",
"watch": "npm-run-all --parallel watch:*",
"web:build-examples": "cd website && node build-examples.js",
"web:build": "npm-run-all web:inject-bundles-misc web:generate web:build-examples web:inject-frontpagecodesample",
"web:bundle-watch-inject": "onchange 'packages/uppy/dist/**/*.css' 'packages/uppy/dist/**/*.js' --initial --verbose -- npm run web:inject-bundles-misc",
"web:clean": "cd website && touch db.json && ./node_modules/.bin/hexo clean",
"web:deploy": "npm-run-all web:clean web:disc web:build && ./bin/web-deploy",
"web:disc": "node ./bin/disc.js",
"web:examples:watch": "cd website && node build-examples.js watch",
"web:examples": "cd website && node build-examples.js",
"web:deploy": "npm-run-all web:clean web:inject-disc web:build && ./bin/web-deploy",
"web:generate": "cd website && touch db.json && ./node_modules/.bin/hexo generate",
"web:inject:frontpagecodesample": "npm run web:generate && cp -f public/frontpage-code-sample.html ./themes/uppy/layout/partials/frontpage-code-sample.html",
"web:inject": "cd website && node inject.js",
"web:inject-bundles-misc": "cd website && node inject.js",
"web:inject-disc": "node ./bin/disc.js",
"web:inject-frontpagecodesample": "npm run web:generate && cp -f website/public/frontpage-code-sample.html website/themes/uppy/layout/partials/frontpage-code-sample.html && touch website/themes/uppy/layout/index.ejs",
"web:install": "cd website && npm install",
"web:preview": "npm-run-all build:lib --parallel web:examples:watch web:bundle:update:watch web:serve",
"web:serve": "cd website && touch db.json &&./node_modules/.bin/hexo server"
"web:start": "npm-run-all build:lib --parallel web:watch-examples web:bundle-watch-inject web:watch",
"web:watch-examples": "cd website && node build-examples.js watch",
"web:watch": "cd website && touch db.json &&./node_modules/.bin/hexo server"
},
"jest": {
"automock": false,
Expand Down
4 changes: 2 additions & 2 deletions test/endtoend/wdio.local.conf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const base = require('./wdio.base.conf')
const { CompanionService } = require('./utils')

// Use "npm run test:acceptance:local -- -b chrome" to test in chrome
// "npm run test:acceptance:local -- -b firefox -b chrome" to test in FF and chrome
// Use "npm run test:endtoend:local -- -b chrome" to test in chrome
// "npm run test:endtoend:local -- -b firefox -b chrome" to test in FF and chrome
let prevIsDashB = false
const capabilities = []
process.argv.forEach((arg) => {
Expand Down
14 changes: 7 additions & 7 deletions website/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const configPath = path.join(webRoot, '/themes/uppy/_config.yml')
const { version } = require(path.join(uppyRoot, '/package.json'))

const defaultConfig = {
comment: 'Auto updated by update.js',
comment: 'Auto updated by inject.js',
uppy_version_anchor: '001',
uppy_version: '0.0.1',
uppy_bundle_kb_sizes: {},
Expand Down Expand Up @@ -57,7 +57,7 @@ const excludes = {
'@uppy/react': ['react']
}

update().catch((err) => {
inject().catch((err) => {
console.error(err)
process.exit(1)
})
Expand All @@ -81,7 +81,7 @@ async function getMinifiedSize (pkg, name) {
}
}

async function updateSizes (config) {
async function injectSizes (config) {
console.info(chalk.grey('Generating bundle sizes…'))
const padTarget = packages.reduce((max, cur) => Math.max(max, cur.length), 0) + 2

Expand Down Expand Up @@ -110,7 +110,7 @@ async function updateSizes (config) {
config.uppy_bundle_kb_sizes = await sizesPromise
}

async function injectBuiltFiles () {
async function injectBundles () {
const cmds = [
`mkdir -p ${path.join(webRoot, '/themes/uppy/source/uppy')}`,
`cp -vfR ${path.join(uppyRoot, '/dist/*')} ${path.join(webRoot, '/themes/uppy/source/uppy/')}`,
Expand Down Expand Up @@ -156,21 +156,21 @@ async function readConfig () {
}
}

async function update () {
async function inject () {
const config = await readConfig()

await injectMarkdown()

config.uppy_version = version
config.uppy_version_anchor = version.replace(/[^\d]+/g, '')
await updateSizes(config)
await injectSizes(config)

const saveConfig = Object.assign({}, defaultConfig, config)
await promisify(fs.writeFile)(configPath, YAML.safeDump(saveConfig), 'utf-8')
console.info(chalk.green('✓ rewritten: '), chalk.grey(configPath))

try {
await injectBuiltFiles()
await injectBundles()
} catch (error) {
console.error(
chalk.red('x failed to inject: '),
Expand Down
Loading

0 comments on commit 5f4f1cf

Please sign in to comment.