Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: saguijs/sagui
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v9.0.0-rc.10
Choose a base ref
...
head repository: saguijs/sagui
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 1,481 additions and 232 deletions.
  1. +2 −0 .gitignore
  2. +43 −14 .travis.yml
  3. +86 −9 README.md
  4. +3 −3 appveyor.yml
  5. +10 −2 bin/ci.js
  6. +37 −28 package.json
  7. +11 −0 spec/fixtures/project-content-with-custom-prettier-options-in-eslintrc/.eslintrc
  8. +8 −0 spec/fixtures/project-content-with-custom-prettier-options-in-eslintrc/src/index.js
  9. +3 −0 spec/fixtures/project-content-with-dynamic-import/src/index.js
  10. +3 −0 spec/fixtures/project-content-with-dynamic-import/src/lib.js
  11. +9 −0 spec/fixtures/project-content-with-invalid-types/index.js
  12. +1 −1 spec/fixtures/project-content-with-lint-errors/index.js
  13. +3 −0 spec/fixtures/project-content-with-prettier-errors-in-sagui-config/sagui.config.js
  14. +5 −0 spec/fixtures/project-content-with-prettier-errors/es6-extension.es6
  15. +3 −0 spec/fixtures/project-content-with-prettier-errors/index.js
  16. +5 −0 spec/fixtures/project-content-with-prettier-errors/js-extension.js
  17. +5 −0 spec/fixtures/project-content-with-prettier-errors/jsx-extension.jsx
  18. +9 −0 spec/fixtures/project-content-with-types/index.js
  19. +1 −3 spec/fixtures/project-content/object-rest.js
  20. +3 −3 spec/fixtures/project-content/object-rest.spec.js
  21. +3 −0 spec/fixtures/project-with-case-mismatch-in-module-paths/src/index.js
  22. 0 spec/fixtures/project-with-case-mismatch-in-module-paths/src/simplemodule.js
  23. +1 −1 spec/fixtures/project-with-css-modules/src/index.js
  24. +6 −0 spec/fixtures/project-with-custom-eslintrc/.eslintrc
  25. +1 −0 spec/fixtures/project-with-existing-gitignore/.gitignore
  26. BIN spec/fixtures/project-with-independent-page/node_modules/.DS_Store
  27. BIN spec/fixtures/project-with-independent-page/node_modules/dependencyA/.DS_Store
  28. +3 −0 spec/fixtures/project-with-independent-page/node_modules/dependencyA/index.js
  29. +14 −0 spec/fixtures/project-with-independent-page/node_modules/dependencyA/package.json
  30. +3 −0 spec/fixtures/project-with-independent-page/node_modules/dependencyB/index.js
  31. +14 −0 spec/fixtures/project-with-independent-page/node_modules/dependencyB/package.json
  32. +7 −0 spec/fixtures/project-with-independent-page/sagui.config.js
  33. +11 −0 spec/fixtures/project-with-independent-page/src/about.html
  34. +5 −0 spec/fixtures/project-with-independent-page/src/about.js
  35. +11 −0 spec/fixtures/project-with-independent-page/src/demo.html
  36. +7 −0 spec/fixtures/project-with-independent-page/src/demo.js
  37. +11 −0 spec/fixtures/project-with-independent-page/src/index.html
  38. +5 −0 spec/fixtures/project-with-independent-page/src/index.js
  39. +1 −0 spec/fixtures/project-with-independent-page/src/shared.js
  40. +5 −0 spec/fixtures/project-with-node-modules/node_modules/dependencyA/index.js
  41. +3 −0 ...res/project-with-node-modules/node_modules/dependencyA/node_modules/transient-dependency/index.js
  42. +5 −0 spec/fixtures/project-with-node-modules/node_modules/dependencyB/index.js
  43. +3 −0 spec/fixtures/project-with-node-modules/node_modules/ovewritten-by-node-modules/index.js
  44. +3 −0 spec/fixtures/project-with-node-modules/node_modules/transient-dependency/index.js
  45. +3 −0 spec/fixtures/project-with-node-modules/sagui.config.js
  46. +9 −0 spec/fixtures/project-with-node-modules/src/index.js
  47. +12 −0 spec/fixtures/project-with-node-modules/src/index.spec.js
  48. +3 −0 spec/fixtures/project-with-node-modules/src/ovewritten-by-node-modules.js
  49. +2 −2 spec/fixtures/project-with-transpile-dependencies/src/index.spec.js
  50. +6 −0 spec/fixtures/project-with-two-pages-disabled-common/sagui.config.js
  51. +11 −0 spec/fixtures/project-with-two-pages-disabled-common/src/about.html
  52. +3 −0 spec/fixtures/project-with-two-pages-disabled-common/src/about.js
  53. +11 −0 spec/fixtures/project-with-two-pages-disabled-common/src/index.html
  54. +3 −0 spec/fixtures/project-with-two-pages-disabled-common/src/index.js
  55. +1 −0 spec/fixtures/project-with-two-pages-disabled-common/src/shared.js
  56. BIN spec/fixtures/project-with-two-pages-enabled-vendor/node_modules/.DS_Store
  57. BIN spec/fixtures/project-with-two-pages-enabled-vendor/node_modules/dependencyA/.DS_Store
  58. +3 −0 spec/fixtures/project-with-two-pages-enabled-vendor/node_modules/dependencyA/index.js
  59. +14 −0 spec/fixtures/project-with-two-pages-enabled-vendor/node_modules/dependencyA/package.json
  60. +3 −0 spec/fixtures/project-with-two-pages-enabled-vendor/node_modules/dependencyB/index.js
  61. +14 −0 spec/fixtures/project-with-two-pages-enabled-vendor/node_modules/dependencyB/package.json
  62. +6 −0 spec/fixtures/project-with-two-pages-enabled-vendor/sagui.config.js
  63. +11 −0 spec/fixtures/project-with-two-pages-enabled-vendor/src/about.html
  64. +5 −0 spec/fixtures/project-with-two-pages-enabled-vendor/src/about.js
  65. +11 −0 spec/fixtures/project-with-two-pages-enabled-vendor/src/index.html
  66. +5 −0 spec/fixtures/project-with-two-pages-enabled-vendor/src/index.js
  67. +1 −0 spec/fixtures/project-with-two-pages-enabled-vendor/src/shared.js
  68. +3 −0 spec/fixtures/project-with-two-pages/sagui.config.js
  69. +11 −0 spec/fixtures/project-with-two-pages/src/about.html
  70. +3 −0 spec/fixtures/project-with-two-pages/src/about.js
  71. +11 −0 spec/fixtures/project-with-two-pages/src/index.html
  72. +3 −0 spec/fixtures/project-with-two-pages/src/index.js
  73. +1 −0 spec/fixtures/project-with-two-pages/src/shared.js
  74. +324 −15 spec/integration/index.integration-spec.js
  75. +2 −0 src/actions.js
  76. +14 −1 src/cli/index.js
  77. +19 −2 src/configure-karma/index.js
  78. +47 −8 src/configure-webpack/build-pages-config.js
  79. +116 −17 src/configure-webpack/build-pages-config.spec.js
  80. +17 −6 src/configure-webpack/index.js
  81. +0 −19 src/configure-webpack/loaders/javascript-eslintrc.json
  82. +13 −13 src/configure-webpack/loaders/javascript.js
  83. +15 −0 src/configure-webpack/loaders/javascript.spec.js
  84. +1 −1 src/configure-webpack/loaders/style.js
  85. +7 −7 src/configure-webpack/loaders/style.spec.js
  86. +6 −6 src/index.js
  87. +31 −0 src/javascript-eslintrc.json
  88. +1 −1 src/run/build.js
  89. +7 −5 src/run/development-server.js
  90. +64 −0 src/run/format.js
  91. +10 −2 src/run/index.js
  92. +0 −45 src/run/install/template.js
  93. +25 −0 src/run/lint.js
  94. +14 −0 src/run/update/gitignore.js
  95. +2 −0 src/run/{install → update}/index.js
  96. +8 −4 src/run/{install → update}/package-json.js
  97. +63 −0 src/run/update/template.js
  98. +8 −0 src/run/{install → update}/udpate-npm-scripts.spec.js
  99. +26 −0 src/run/update/update-gitignore.js
  100. +51 −0 src/run/update/update-gitignore.spec.js
  101. +5 −1 src/run/{install → update}/update-npm-scripts.js
  102. +32 −2 src/sagui-config-schema.json
  103. +4 −0 src/util/log.js
  104. +1 −1 template/base/sagui.config.js
  105. +2 −4 template/base/src/index.spec.js
  106. 0 template/dot-files/{editorconfig → .editorconfig}
  107. +2 −0 template/dot-files/.eslintignore
  108. +3 −0 template/dot-files/.eslintrc
  109. 0 template/dot-files/{flowconfig → .flowconfig}
  110. +0 −6 template/dot-files/gitignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,5 @@ node_modules
lib
tmp
npm-debug.log
package-lock.json
yarn.lock
57 changes: 43 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
language: node_js
node_js:
- 6.9.2
- 7.3.0
sudo: false

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash # until yarn is
- export PATH=$HOME/.yarn/bin:$PATH # pre-installed
- curl -o- -L https://yarnpkg.com/install.sh | bash # until yarn is
- export PATH=$HOME/.yarn/bin:$PATH # pre-installed

script:
- node bin/ci.js
env:
matrix:
- TEST_TYPE=lint_and_test_unit
- TEST_TYPE=integration_test
- TEST_TYPE=test_create_project_npm
- TEST_TYPE=test_create_project_yarn
- node bin/ci.js

matrix:
include:
- sudo: false
env: TEST_TYPE=lint_and_test_unit
node_js: 6.11.1

# test creating a new project with the LTS version
- sudo: false
env: TEST_TYPE=test_create_project_npm
node_js: 6.11.1

# test creating a new project with the latest version
- sudo: false
env: TEST_TYPE=test_create_project_npm
node_js: 8.4.0

- sudo: false
env: TEST_TYPE=test_create_project_yarn
node_js: 6.11.1

# Test with Chrome available
- dist: trusty
addons:
chrome: stable
sudo: false
env:
- TEST_TYPE=integration_test
- BROWSER=Chrome
node_js: 6.11.1

cache:
directories:
- node_modules
- node_modules

before_deploy:
- npm prune
- npm run build

deploy:
skip_cleanup: true
provider: npm
email: paulo@ragonha.me
api_key:
95 changes: 86 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Deprecated

When Sagui was created, the frontend landscape was in a much different situation than it is today. Creating projects was a hell and we all faced the now infamous "JavaScript fatigue". Fast-forward to 2019 and we now have established solutions such as [create-react-app](https://github.com/facebook/create-react-app) that have a large community behind and is being well maintained. Therefore there is no longer a need for Sagui to exist.

This was a fantastic ride and I've learned a lot while building this little tool.

Thanks to all the community who help me along the way! ❤️🐒

![Sagui](https://raw.githubusercontent.com/saguijs/sagui/master/banner.jpg)

[![Build Status](https://travis-ci.org/saguijs/sagui.svg)](https://travis-ci.org/saguijs/sagui)
@@ -25,7 +33,7 @@ npm init -y
**Install Sagui locally** as a development dependency:

```bash
npm install --save-dev sagui@beta
npm install --save-dev sagui
```

Start the development server:
@@ -56,8 +64,10 @@ Sagui manages the [package.json](https://docs.npmjs.com/files/package.json) scri

- `npm run build`: build a development version of the project;
- `npm run dist`: build an optimized (ready for deployment) version of the project;
- `npm run start`: spin up a development server with live-reload and [HMR](http://webpack.github.io/docs/hot-module-replacement.html);
- `npm run start`: spin up a development server with live-reload and [HMR](https://webpack.js.org/concepts/hot-module-replacement/);
- `npm run format`: automatically format the code using [prettier](https://github.com/prettier/prettier);
- `npm run test`: run all test related scripts below;
- `npm run test:lint`: run static analysis in the code;
- `npm run test:unit`: run the unit tests;
- `npm run test:typecheck`: run the static type analysis in the code;
- `npm run test:unit:watch`: run a test watcher (great for development and debugging).
@@ -72,11 +82,9 @@ As stated earlier, Sagui strives to provide all the basic needs to create modern

The development server out-of-the-box has live reloading and **hot-module replacement**.

[ReactJS](http://reactjs.com/) has first-class support via [react-transform](https://github.com/gaearon/babel-plugin-react-transform), so updating components' source reflects instantly (without full refresh) in the browser.

### Build

Sagui uses [Webpack](http://webpack.github.io/) as its underlying bundling tool. The biggest feature that Webpack provides is that everything is a module. Sagui supports the following module types by default:
Sagui uses [Webpack](https://webpack.js.org/) as its underlying bundling tool. The biggest feature that Webpack provides is that everything is a module. Sagui supports the following module types by default:

- Fonts (`.woff`, `.woff2`, `.ttf`, `.eot`, `.otf`)
- HTML (`.html`)
@@ -91,7 +99,7 @@ Sagui uses [Webpack](http://webpack.github.io/) as its underlying bundling tool.
During build, optimizations and special processing are also performed in the output bundle:

- [Autoprefixer for CSS properties](https://github.com/postcss/autoprefixer) for cross-browser support;
- [Commons code splitting](https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin) if there is more than a single entry-point;
- [Commons code splitting](https://webpack.js.org/plugins/commons-chunk-plugin/) if there is more than a single entry-point;
- [Extract styles as separated files](https://github.com/webpack/extract-text-webpack-plugin) to style the page before the JavaScript is loaded and parsed;
- Minification and code dedupication.

@@ -108,13 +116,32 @@ Sagui will automatically run every test file that follows this convention.

Under the hood it uses [Karma test runner](http://karma-runner.github.io/) to allow running the tests in the most diverse browsers and even through [Selenium](http://docs.seleniumhq.org/) (not natively).

By default Sagui uses [PhantomJS](http://phantomjs.org/) to run the tests headlessly. To **speed up installing the dependencies** (`npm install`) it is advisable to have PhantomJS [installed globally](https://github.com/Medium/phantomjs#using-phantomjs-from-disk) in the machine.
To run the tests Sagui uses [Chrome Headless](https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md), but it fallbacks to [PhantomJS](http://phantomjs.org/) if Chrome is not installed on the machine.

Make sure either of these browsers is installed to be able to run the tests:

- [Chrome](https://www.google.com/chrome/browser/desktop/index.html)
- [PhantomJS](https://github.com/Medium/phantomjs#using-phantomjs-from-disk)

To open the tests in a browser (or in multiple browsers!), simply follow the link Karma outputs when you start running the script `test:unit:watch`. Running them in a browser allows you to set breakpoints and debug your code properly. Note watch mode is necessary, else tests will stop running when finished.

#### Linting
#### Code formatting

We expect the code to be formatted using [prettier](https://github.com/prettier/prettier). Sagui has a script that can apply the expected code format for you, simply run:

```bash
npm run format
```

To get the code formatted automatically for you, it is recommended that you install the [prettier plugin](https://atom.io/packages/prettier-atom) in your editor of choice with the same configuration that is used by Sagui:

- singleQuote: `true`
- parser: `babylon`
- semi: `false`
- printWidth: `100`
- trailingComma: `es5`

Static code analysis is also performed on the code following the [JavaScript Standard Style](http://standardjs.com/) convention.
Prettier is combined with the [JavaScript Standard Style](http://standardjs.com/) convention to check for common errors in the code.

#### Static type checking

@@ -153,6 +180,43 @@ The previous configuration will expect and build the files:
- `src/index.html` => `dist/index.html`
- `src/index.js` => `dist/index.js`

#### Excluding a page from chunks

If you want a page to be excluded from either the [vendor](#chunksvendor) or [common](#chunkscommon) chunk, then you can do so by providing an object with a `name` and `independent` flag (set to `true`) instead of just the name of the page.

```js
// sagui.config.js
module.exports = {
pages: ['index', 'about', { name: 'demo', independent: true }]
}
```

### `chunks.vendor`

If you want all your external dependencies (`node_modules`) in your [pages](#pages) to be bundled together in a "vendor" chunk, then set this flag to `true`. By default it is set to `false`.

```js
// sagui.config.js
module.exports = {
chunks: {
vendor: true
}
}
```

### `chunks.common`

If you do not want all the common dependencies of your [pages](#pages) to be bundled together in a "common" chunk, then set this flag to `false`. By default it is set to `true`.

```js
// sagui.config.js
module.exports = {
chunks: {
common: false
}
}
```

### `libraries`

Create **reusable libraries** that can be shared across applications. Sagui will take care of the build process so that external libraries are not bundled and that you have a CommonJS module as the output.
@@ -395,6 +459,19 @@ For more information about configuring Karma, check the [Karma documentation](ht

## Gotchas

### `Invalid Host header` - Accessing dev server from outside `localhost`

By default, Webpack disables access to the development server for hosts other than `localhost`, which means the development server will not be accessible from outside. If you want to give external access to the development server, you can set the `develop.disableHostCheck` to `true`:

```js
// sagui.config.js
module.exports = {
develop: {
disableHostCheck: true
}
}
```

### React Router

For [`react-router`](https://github.com/ReactTraining/react-router) to work on the development server, an absolute static path for the output has to be configured on Webpack. You can do that by adding this configuration to `sagui.config.js`:
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@ version: "{build}"

environment:
matrix:
- nodejs_version: "6.2.0"
- nodejs_version: "8.1.4"
platform: x64
TEST_TYPE: lint_and_test_unit

- nodejs_version: "6.2.0"
- nodejs_version: "8.1.4"
platform: x64
TEST_TYPE: integration_test

- nodejs_version: "6.2.0"
- nodejs_version: "8.1.4"
platform: x64
TEST_TYPE: test_create_project_npm

12 changes: 10 additions & 2 deletions bin/ci.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env node
var path = require('path')
var saguiPath = path.join(__dirname, '..')
var version = require('../package.json').version
var tgzFile = path.join(saguiPath, `sagui-${version}.tgz`)

console.log('ENVIRONMENT', process.env)

@@ -26,31 +28,37 @@ if (process.env.TEST_TYPE === 'integration_test') {
if (process.env.TEST_TYPE === 'test_create_project_npm') {
// # builds Sagui before installing
exec('npm run build', saguiPath)
exec('npm pack --ignore-scripts')

var npmProjectPath = createTempFolder()

// # Create a new project and install Sagui
exec('npm init -y .', npmProjectPath)
exec('npm install --save-dev file://' + saguiPath, npmProjectPath)
exec(`npm install --save-dev ${tgzFile}`, npmProjectPath)

// # Run some basic scripts
exec('npm test', npmProjectPath)
exec('npm run test:lint', npmProjectPath)
exec('npm run build', npmProjectPath)
exec('npm run dist', npmProjectPath)
exec('npm run format', npmProjectPath)
}

if (process.env.TEST_TYPE === 'test_create_project_yarn') {
// # builds Sagui before installing
exec('npm run build', saguiPath)
exec('npm pack --ignore-scripts')

var yarnProjectPath = createTempFolder()

// # Create a new project and install Sagui
exec('yarn init -y .', yarnProjectPath)
exec('yarn add --dev file://' + saguiPath, yarnProjectPath)
exec(`yarn add --dev ${tgzFile}`, yarnProjectPath)

// # Run some basic scripts
exec('yarn test', yarnProjectPath)
exec('yarn run test:lint', yarnProjectPath)
exec('yarn run build', yarnProjectPath)
exec('yarn run dist', yarnProjectPath)
exec('yarn run format', yarnProjectPath)
}
Loading