Procházet zdrojové kódy

Merge pull request #602 from ckeditor/t/473

Internal: Removed gulp dependency in favor of npm scripts. Closes #473.
Piotrek Koszuliński před 8 roky
rodič
revize
9ee98b93db

+ 3 - 3
.travis.yml

@@ -15,12 +15,12 @@ before_install:
   - export DISPLAY=:99.0
   - sh -e /etc/init.d/xvfb start
 install:
-  - npm install mgit2 lerna gulp @ckeditor/ckeditor5-dev-tests @ckeditor/ckeditor5-dev-docs
+  - npm install mgit2 lerna @ckeditor/ckeditor5-dev-tests @ckeditor/ckeditor5-dev-docs
   - mgit bootstrap --resolver-url-template="https://github.com/\${ path }.git"
   - lerna bootstrap
 script:
-  - npm t
-  - gulp docs:api --validate-only
+  - npm t -- --reporter=dots
+  - npm run docs:api -- --validate-only
 after_success:
   - travis_wait ./node_modules/.bin/ckeditor5-dev-docs-publish-nightly
 notifications:

+ 6 - 7
docs/framework/guides/contributing/development-environment.md

@@ -27,14 +27,13 @@ In order to start developing CKEditor 5 you will require:
 
 First, you need to install a couple of tools which you will be using later:
 
-* [gulp](http://gulpjs.com/) (a JavaScript task runner),
 * [mgit](https://www.npmjs.com/package/mgit2) (a multi-repo management tool),
 * [Lerna.js](https://github.com/lerna/lerna) (a multi-package management tool).
 
 It is best to install them globally in your system for an easier use later on:
 
 ```bash
-npm install -g gulp lerna mgit2
+npm install -g lerna mgit2
 ```
 
 Note: You may need to use `sudo` on Linux and macOS.
@@ -103,7 +102,7 @@ lrwxr-xr-x    1 p  staff    25 31 Jan 10:37 ckeditor5-engine -> ../../../ckedito
 If everything worked correctly, you should be able to run some tests:
 
 ```bash
-gulp test --files=core
+npm run test -- --files=core
 ```
 
 ### Fetching changes
@@ -153,13 +152,13 @@ Lerna is a tool used by many well-known projects such as [Babel.js](https://gith
 In order to run tests you need to use the `test` and `test:manual` tasks.
 
 ```bash
-gulp test --watch --coverage --source-map --files=engine
+npm test -- --watch --coverage --source-map --files=engine
 ```
 
 or, shorter:
 
 ```bash
-gulp test -wcs --files=engine
+npm test -- -wcs --files=engine
 ```
 
 This command will run the [`ckeditor5-engine`](https://github.com/ckeditor/ckeditor5-engine) package's tests.
@@ -169,7 +168,7 @@ This command will run the [`ckeditor5-engine`](https://github.com/ckeditor/ckedi
 To create a server for manual tests use the `test:manual` task:
 
 ```bash
-gulp test:manual
+npm run test:manual
 ```
 
 It accepts the `--source-map` (`-s`) option. Note that it watches for changes only in the JavaScript files (see the [bug](https://github.com/ckeditor/ckeditor5-dev/issues/52)).
@@ -187,7 +186,7 @@ npm run install-optional-dependencies
 Then you can run the `docs` task:
 
 ```bash
-gulp docs
+npm run docs
 ```
 
 The documentation will be available in `build/docs/`.

+ 7 - 11
docs/framework/guides/contributing/testing-environment.md

@@ -9,19 +9,15 @@ Before reading this article we recommend getting familiar with the CKEditor 5 {@
 
 ## Introduction
 
-The CKEditor 5 testing environment uses a popular setup with [Karma](https://karma-runner.github.io), [webpack](https://webpack.github.io/), [babel-loader](https://github.com/babel/babel-loader) and [Istanbul](https://github.com/gotwarlost/istanbul). We created some [gulp](https://github.com/gulpjs/gulp) tasks which glue all these pieces and special requirements for CKEditor together.
-
-<info-box>
-	We are [considering dropping gulp and switching to npm scripts](https://github.com/ckeditor/ckeditor5/issues/473), so please do not be surprised that both methods are in use now.
-</info-box>
+The CKEditor 5 testing environment uses a popular setup with [Karma](https://karma-runner.github.io), [webpack](https://webpack.github.io/), [babel-loader](https://github.com/babel/babel-loader) and [Istanbul](https://github.com/gotwarlost/istanbul). We created some [npm scripts](https://docs.npmjs.com/cli/run-script) which glue all these pieces and special requirements for CKEditor together.
 
 Each CKEditor package has its own tests suite (see for example the [engine's tests](https://github.com/ckeditor/ckeditor5-engine/tree/master/tests)), however, the test runner is available in the [`ckeditor5`](https://github.com/ckeditor/ckeditor5) package which is the central development environment. The actual code of the test runner is implemented in the [`@ckeditor/ckeditor5-dev-tests`](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-tests) package and can be easily reused outside of `ckeditor5`.
 
 ## Running automated tests
 
-In order to run the automated tests use the `gulp test` task.
+In order to run the automated tests use the `npm test [-- <args>...]` command.
 
-It accepts the following arguments:
+It accepts the following arguments (must be passed after the `--` option):
 
 * `--watch` (alias `-w`) &ndash; Whether to watch the files and execute tests whenever any file changes.
 * `--source-map` (alias `-s`) &ndash; Whether to generate the source maps.
@@ -35,24 +31,24 @@ It accepts the following arguments:
 Run all tests with the code coverage check of the [`ckeditor5-core`](https://github.com/ckeditor/ckeditor5-core) package:
 
 ```
-gulp test -c --files=core
+npm test -- -c --files=core
 ```
 
 Run and watch the [engine's `view` namespace tests](https://github.com/ckeditor/ckeditor5-engine/tree/master/tests/view) and all the tests in [`ckeditor5-typing`](https://github.com/ckeditor/ckeditor5-typing):
 
 ```
-gulp test -cw --files=engine/view,typing
+npm test -- -cw --files=engine/view,typing
 ```
 
 Run the `bold*.js` tests in the [`ckeditor5-basic-styles`](https://github.com/ckeditor/ckeditor5-basic-styles) package:
 
 ```
-gulp test -cw --files=basic-styles/bold*.js
+npm test -- -cw --files=basic-styles/bold*.js
 ```
 
 ## Running manual tests
 
-In order to start the manual tests server use the `gulp test:manual` task.
+In order to start the manual tests server use the `npm run test:manual` task.
 
 The task accepts the `--source-map` (alias `-s`) option.
 

+ 15 - 8
package.json

@@ -21,7 +21,7 @@
     "@ckeditor/ckeditor5-build-classic": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-build-inline": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-clipboard": "^1.0.0-alpha.1",
-    "@ckeditor/ckeditor5-cloudeservices": "ckeditor/ckeditor5-cloudservices",
+    "@ckeditor/ckeditor5-cloudservices": "^0.0.1",
     "@ckeditor/ckeditor5-core": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-easy-image": "^1.0.0-alpha.1",
     "@ckeditor/ckeditor5-editor-balloon": "^1.0.0-alpha.1",
@@ -45,11 +45,10 @@
     "@ckeditor/ckeditor5-widget": "^1.0.0-alpha.1"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-docs": "^7.5.1",
-    "@ckeditor/ckeditor5-dev-tests": "^8.2.5",
+    "@ckeditor/ckeditor5-dev-docs": "^8.0.0",
+    "@ckeditor/ckeditor5-dev-tests": "^9.0.0",
     "eslint": "^4.8.0",
     "eslint-config-ckeditor5": "^1.0.6",
-    "gulp": "^3.9.1",
     "husky": "^0.14.3",
     "lint-staged": "^4.2.3",
     "lerna": "^2.2.0",
@@ -70,10 +69,18 @@
   "scripts": {
     "lint": "eslint --quiet '**/*.js'",
     "precommit": "lint-staged",
-    "test": "node --max_old_space_size=4096 ./node_modules/.bin/ckeditor5-dev-tests --reporter=dots",
-    "install-optional-dependencies": "./scripts/install-optional-dependencies.sh",
-    "switch-to-dev-dev": "./scripts/switch-to-dev-dev.sh",
-    "build-and-publish-docs": "./scripts/docs/build-and-publish.js"
+    "test": "node --max_old_space_size=4096 ./node_modules/.bin/ckeditor5-dev-tests",
+    "test:manual": "node --max_old_space_size=4096 ./node_modules/.bin/ckeditor5-dev-tests-manual",
+    "docs": "node ./scripts/docs/build-docs.js",
+    "docs:api": "node ./scripts/docs/build-api-docs.js",
+    "translations:collect": "ckeditor5-dev-env-translations collect",
+    "translations:download": "ckeditor5-dev-env-translations download",
+    "translations:upload": "ckeditor5-dev-env-translations upload",
+    "changelog": "node ./scripts/release/changelog.js",
+    "release:dependencies": "node ./scripts/release/release-dependencies.js",
+    "install-optional-dependencies": "sh ./scripts/install-optional-dependencies.sh",
+    "switch-to-dev-dev": "sh ./scripts/switch-to-dev-dev.sh",
+    "build-and-publish-docs": "node ./scripts/docs/build-and-publish.js"
   },
   "lint-staged": {
     "**/*.js": [

+ 1 - 1
scripts/docs/build-and-publish.js

@@ -21,7 +21,7 @@ console.log( 'Updating your ckeditor5.github.io clone...' );
 exec( 'cd ../ckeditor5.github.io && git pull && cd -' );
 
 console.log( 'Building documentation...' );
-exec( 'gulp docs --production' );
+exec( 'npm run docs -- --production' );
 
 console.log( 'Copying files...' );
 

+ 14 - 0
scripts/docs/build-api-docs.js

@@ -0,0 +1,14 @@
+#!/usr/bin/env node
+
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+const buildApiDocs = require( './buildapi' );
+
+buildApiDocs();

+ 63 - 0
scripts/docs/build-docs.js

@@ -0,0 +1,63 @@
+#!/usr/bin/env node
+
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+const assertIsInstalled = require( './../utils/assertisinstalled' );
+const buildApiDocs = require( './buildapi' );
+
+const skipLiveSnippets = process.argv.includes( '--skip-snippets' );
+const skipApi = process.argv.includes( '--skip-api' );
+const production = process.argv.includes( '--production' );
+
+buildDocs();
+
+function buildDocs() {
+	if ( skipApi ) {
+		const fs = require( 'fs' );
+		const apiJsonPath = './docs/api/output.json';
+
+		if ( fs.existsSync( apiJsonPath ) ) {
+			fs.unlinkSync( apiJsonPath );
+		}
+
+		runUmberto( {
+			skipLiveSnippets,
+			skipApi,
+			production
+		} ).then( () => process.exit() );
+
+		return;
+	}
+
+	// Simple way to reuse existing api/output.json:
+	// return Promise.resolve()
+	buildApiDocs()
+		.then( () => {
+			return runUmberto( {
+				skipLiveSnippets,
+				production
+			} );
+		} );
+}
+
+function runUmberto( options ) {
+	assertIsInstalled( 'umberto' );
+	const umberto = require( 'umberto' );
+
+	return umberto.buildSingleProject( {
+		configDir: 'docs',
+		clean: true,
+		skipLiveSnippets: options.skipLiveSnippets,
+		snippetOptions: {
+			production: options.production
+		},
+		skipApi: options.skipApi
+	} );
+}

+ 29 - 0
scripts/docs/buildapi.js

@@ -0,0 +1,29 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+const path = require( 'path' );
+
+const assertIsInstalled = require( './../utils/assertisinstalled' );
+
+module.exports = function buildApiDocs() {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-docs' );
+
+	const ckeditor5Docs = require( '@ckeditor/ckeditor5-dev-docs' );
+
+	return ckeditor5Docs
+		.build( {
+			readmePath: path.join( process.cwd(), 'README.md' ),
+			sourceFiles: [
+				process.cwd() + '/packages/ckeditor5-*/src/**/*.@(js|jsdoc)',
+				'!' + process.cwd() + '/packages/ckeditor5-*/src/lib/**/*.js',
+				'!' + process.cwd() + '/packages/ckeditor5-build-*/src/**/*.js'
+			],
+			validateOnly: process.argv[ 3 ] == '--validate-only'
+		} );
+};

+ 4 - 4
scripts/install-optional-dependencies.sh

@@ -6,10 +6,10 @@
 # Installs optional dev dependencies.
 # They are required by the following tasks:
 #
-# * gulp docs
-# * gulp changelog:dependencies
-# * gulp release:dependencies
-# * gulp translations:*
+# * npm run docs
+# * npm run changelog:dependencies
+# * npm run release:dependencies
+# * npm run translations:*
 
 set -e
 

+ 38 - 0
scripts/release/changelog.js

@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+const assertIsInstalled = require( './../utils/assertisinstalled' );
+
+assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
+const devEnv = require( '@ckeditor/ckeditor5-dev-env' );
+const commonOptions = {
+	cwd: process.cwd(),
+	packages: 'packages'
+};
+const editorBuildsGlob = '@ckeditor/ckeditor5-build-*';
+
+const optionsForDependencies = Object.assign( {}, commonOptions, {
+	skipPackages: editorBuildsGlob
+} );
+const optionsForBuilds = Object.assign( {}, commonOptions, {
+	scope: editorBuildsGlob
+} );
+
+Promise.resolve()
+	.then( () => devEnv.generateChangelogForSubRepositories( optionsForDependencies ) )
+	.then( () => devEnv.generateSummaryChangelog( optionsForBuilds ) )
+	.then( () => {
+		console.log( 'Done!' );
+	} )
+	.catch( err => {
+		console.error( err.stack );
+	} );

+ 20 - 0
scripts/release/release-dependencies.js

@@ -0,0 +1,20 @@
+#!/usr/bin/env node
+
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+const assertIsInstalled = require( './../utils/assertisinstalled' );
+
+assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
+require( '@ckeditor/ckeditor5-dev-env' )
+	.releaseSubRepositories( {
+		cwd: process.cwd(),
+		packages: 'packages'
+	} );

+ 20 - 0
scripts/utils/assertisinstalled.js

@@ -0,0 +1,20 @@
+/**
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* eslint-env node */
+
+'use strict';
+
+module.exports = function assertIsInstalled( packageName ) {
+	try {
+		require( packageName + '/package.json' );
+	} catch ( err ) {
+		console.error( `Error: Cannot find package '${ packageName }'.\n` );
+		console.error( 'You need to install optional dependencies.' );
+		console.error( 'Run: \'npm run install-optional-dependencies\'.' );
+
+		process.exit( 1 );
+	}
+};