Browse Source

Merge branch 'master' into t/429

Piotrek Koszuliński 8 years ago
parent
commit
e938f0329d

+ 1 - 0
.gitignore

@@ -8,4 +8,5 @@ node_modules/**
 build/**
 coverage/**
 packages/**
+docs/api/output.json
 lerna-debug.log

File diff suppressed because it is too large
+ 24 - 0
docs/assets/img/project-logo.svg


+ 7 - 0
docs/guides/end-user-features/end-user-features.md

@@ -0,0 +1,7 @@
+---
+title: End User Features Example Guide
+category-id: end-user-features
+slug: euf
+order: 90
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 6 - 0
docs/guides/getting-started/getting-started.md

@@ -0,0 +1,6 @@
+---
+title: Getting started
+category-id: getting-started
+order: 50
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 5 - 0
docs/guides/index.md

@@ -0,0 +1,5 @@
+---
+title: Guides Index Page
+category-id: guides
+order: 10
+---

+ 6 - 0
docs/guides/inserting-ckeditor/another-guide.md

@@ -0,0 +1,6 @@
+---
+title: Another guide about inserting CKEditor
+category-id: inserting-ckeditor
+order: 40
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 6 - 0
docs/guides/inserting-ckeditor/inserting.md

@@ -0,0 +1,6 @@
+---
+title: Inserting
+category-id: inserting-ckeditor
+order: 40
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 4 - 0
docs/index.md

@@ -0,0 +1,4 @@
+---
+title: CKEditor 5 Documentation
+order: 10
+---

+ 6 - 0
docs/tutorials/advanced-tutorials/advanced.md

@@ -0,0 +1,6 @@
+---
+title: Advanced Tutorial
+category-id: advanced-tutorials
+order: 30
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 6 - 0
docs/tutorials/how-to/how-to-artcle.md

@@ -0,0 +1,6 @@
+---
+title: Another tutorial example
+category-id: how-to
+order: 30
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 6 - 0
docs/tutorials/index.md

@@ -0,0 +1,6 @@
+---
+title: Tutorials Index Page
+category-id: tutorials
+order: 30
+---
+

+ 6 - 0
docs/tutorials/step-by-step/step-by-step-article.md

@@ -0,0 +1,6 @@
+---
+title: Example Tutorial
+category-id: step-by-step
+order: 30
+---
+Lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ 80 - 0
docs/umberto.json

@@ -0,0 +1,80 @@
+{
+	"name": "CKEditor 5",
+	"slug": "ckeditor5",
+	"hexo-config": "docs/hexo-custom-config.json",
+	"path": "docs",
+	"groups": [
+		{
+			"name": "API",
+			"id": "api-reference",
+			"sourceDir": "api",
+			"slug": "api",
+			"type": "jsdoc"
+		},
+		{
+			"name": "Guides",
+			"id": "guides",
+			"slug": "guides",
+			"categories": [
+				{
+					"name": "Getting started",
+					"id": "getting-started",
+					"slug": "getting-started",
+					"order": 10,
+					"categories": [
+						{
+							"name": "Inserting CKEditor",
+							"id": "inserting-ckeditor",
+							"slug": "inserting-ckeditor",
+							"order": 10
+						},
+						{
+							"name": "End User Features",
+							"id": "end-user-features",
+							"order": 20
+						}
+					]
+				},
+			  	{
+				  	"name": "Plugins",
+				  	"id": "plugins",
+				  	"slug": "plugins",
+				  	"order": 30
+				}
+			]
+		},
+		{
+			"name": "Tutorials",
+			"id": "tutorials",
+			"slug": "tutorials",
+			"categories": [
+				{
+					"name": "How to",
+					"id": "how-to",
+					"slug": "how-to",
+					"order": 20,
+					"categories": [
+						{
+							"name": "Step by step",
+							"id": "step-by-step",
+							"slug": "step-by-step",
+							"order": 10
+						}
+					]
+				},
+				{
+					"name": "Advanced tutorials",
+					"id": "advanced-tutorials",
+					"slug": "advanced-tutorials",
+					"order": 10
+				}
+			]
+		}
+	],
+	"items": [
+		{
+			"path": "packages/ckeditor5-autoformat",
+			"prefix": "autoformat"
+		}
+	]
+}

+ 48 - 14
gulpfile.js

@@ -16,20 +16,6 @@ gulp.task( 'lint', ckeditor5Lint.lint );
 gulp.task( 'lint-staged', ckeditor5Lint.lintStaged );
 gulp.task( 'pre-commit', [ 'lint-staged' ] );
 
-// Documentation. -------------------------------------------------------------
-
-gulp.task( 'docs', () => {
-	return require( '@ckeditor/ckeditor5-dev-docs' )
-		.build( {
-			readmePath: path.join( process.cwd(), 'README.md' ),
-			sourceFiles: [
-				process.cwd() + '/packages/ckeditor5-*/src/**/*.@(js|jsdoc)',
-				'!' + process.cwd() + '/packages/ckeditor5-*/src/lib/**/*.js'
-			],
-			destinationPath: path.join( process.cwd(), 'build', 'docs' )
-		} );
-} );
-
 // Tests. ---------------------------------------------------------------------
 
 gulp.task( 'test', () => {
@@ -47,23 +33,55 @@ function getTestOptions() {
 		.parseArguments( process.argv.slice( 2 ) );
 }
 
+// Documentation. -------------------------------------------------------------
+
+gulp.task( 'docs', () => {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-docs' );
+	assertIsInstalled( 'umberto' );
+
+	const umberto = require( 'umberto' );
+	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'
+			]
+		} )
+		.then( () => {
+			return umberto.buildSingleProject( {
+				configDir: 'docs',
+				clean: true
+			} );
+		} );
+} );
+
 // Translations. --------------------------------------------------------------
 
 gulp.task( 'translations:collect', () => {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
 	return require( '@ckeditor/ckeditor5-dev-env' ).collectTranslations();
 } );
 
 gulp.task( 'translations:upload', () => {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
 	return require( '@ckeditor/ckeditor5-dev-env' ).uploadTranslations();
 } );
 
 gulp.task( 'translations:download', () => {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
 	return require( '@ckeditor/ckeditor5-dev-env' ).downloadTranslations();
 } );
 
 // Releasing. -----------------------------------------------------------------
 
 gulp.task( 'changelog:dependencies', () => {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
 	return require( '@ckeditor/ckeditor5-dev-env' )
 		.generateChangelogForSubRepositories( {
 			cwd: process.cwd(),
@@ -72,9 +90,25 @@ gulp.task( 'changelog:dependencies', () => {
 } );
 
 gulp.task( 'release:dependencies', () => {
+	assertIsInstalled( '@ckeditor/ckeditor5-dev-env' );
+
 	return require( '@ckeditor/ckeditor5-dev-env' )
 		.releaseSubRepositories( {
 			cwd: process.cwd(),
 			packages: 'packages'
 		} );
 } );
+
+// Utils. ---------------------------------------------------------------------
+
+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 );
+	}
+}

+ 3 - 3
package.json

@@ -34,8 +34,6 @@
     "@ckeditor/ckeditor5-widget": "^0.1.0"
   },
   "devDependencies": {
-    "@ckeditor/ckeditor5-dev-docs": "^6.1.6",
-    "@ckeditor/ckeditor5-dev-env": "^4.4.0",
     "@ckeditor/ckeditor5-dev-lint": "^2.0.2",
     "@ckeditor/ckeditor5-dev-tests": "^7.3.0",
     "gulp": "^3.9.0",
@@ -56,6 +54,8 @@
     "url": "https://github.com/ckeditor/ckeditor5.git"
   },
   "scripts": {
-    "test": "node --max_old_space_size=4096 ./node_modules/.bin/ckeditor5-dev-tests --reporter=dots"
+    "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"
   }
 }

+ 0 - 46
scripts/fix-src-imports.js

@@ -1,46 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-const fs = require( 'fs' );
-const path = require( 'path' );
-const glob = require( 'glob' );
-
-const srcDir = path.join( process.cwd(), 'src' );
-const srcPath = path.join( srcDir, '**', '*.js' );
-
-for ( const filePath of glob.sync( srcPath ) ) {
-	const fileDepth = countOcurrences( filePath.replace( srcDir + '/', '' ), path.sep );
-	const fix = ( wholeImport, pathStart ) => fixImport( wholeImport, pathStart, fileDepth );
-
-	const fileContent = fs.readFileSync( filePath, 'utf-8' )
-		.replace( /\nimport[^']+?'((\.\.\/)+[\w-]+)\/[^']+?'/gm, fix );
-
-	fs.writeFileSync( filePath, fileContent, 'utf-8' );
-}
-
-function fixImport( wholeImport, pathStart, fileDepth ) {
-	const indexOfPathStart = wholeImport.indexOf( '../' );
-	const packageShortName = pathStart.split( '/' ).slice( -1 )[ 0 ];
-	const importDepth = countOcurrences( pathStart, '../' );
-
-	if ( importDepth <= fileDepth ) {
-		return wholeImport;
-	}
-
-	return (
-		wholeImport.slice( 0, indexOfPathStart ) +
-		'ckeditor5-' + packageShortName +
-		'/src' +
-		wholeImport.slice( indexOfPathStart + pathStart.length )
-	);
-}
-
-function countOcurrences( str, pattern ) {
-	return str.split( pattern ).length - 1;
-}

+ 0 - 59
scripts/fix-test-imports.js

@@ -1,59 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-const fs = require( 'fs' );
-const path = require( 'path' );
-const glob = require( 'glob' );
-
-const testDir = path.join( process.cwd(), 'tests' );
-const testPath = path.join( testDir , '**', '*.js' );
-
-for ( const filePath of glob.sync( testPath ) ) {
-	const fileContent = fs.readFileSync( filePath, 'utf-8' )
-		.replace( /\nimport[^']+?'([^']+?)'/gm, fixImport );
-
-	fs.writeFileSync( filePath, fileContent , 'utf-8' );
-}
-
-function fixImport( wholeImport , path ) {
-	let fixedImport = fixCkeditorPaths( wholeImport, path );
-	fixedImport = fixTestPaths( fixedImport, path );
-
-	return fixedImport;
-}
-
-function fixCkeditorPaths( wholeImport, path ) {
-	if ( path.indexOf( 'ckeditor5/' ) !== 0 ) {
-		return wholeImport;
-	}
-
-	const index = wholeImport.indexOf( path );
-	const pathChunks = path.split( '/' );
-
-	return (
-		wholeImport.slice( 0, index ) +
-		'ckeditor5-' + pathChunks[ 1 ] + '/src/' + pathChunks.slice( 2 ).join( '/' ) +
-		wholeImport.slice( path.length + index )
-	);
-}
-
-function fixTestPaths( wholeImport, path ) {
-	if ( path.indexOf( 'tests/' ) !== 0 ) {
-		return wholeImport;
-	}
-
-	const index = wholeImport.indexOf( path );
-	const pathChunks = path.split( '/' );
-
-	return (
-		wholeImport.slice( 0, index ) +
-		'ckeditor5-' + pathChunks[ 1 ] + '/tests/' + pathChunks.slice( 2 ).join( '/' ) +
-		wholeImport.slice( path.length + index )
-	);
-}

+ 16 - 0
scripts/install-optional-dependencies.sh

@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
+# For licensing, see LICENSE.md.
+
+# Installs optional dev dependencies.
+# They are required by the following tasks:
+#
+# * gulp docs
+# * gulp changelog:dependencies
+# * gulp release:dependencies
+# * gulp translations:*
+
+set -e
+
+npm i @ckeditor/ckeditor5-dev-docs @ckeditor/ckeditor5-dev-env umberto

+ 0 - 21
scripts/remove-js-extensions-from-imports.js

@@ -1,21 +0,0 @@
-#!/usr/bin/env node
-
-/**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
-
-'use strict';
-
-const fs = require( 'fs' );
-const path = require( 'path' );
-const glob = require( 'glob' );
-
-const srcPath = path.join( process.cwd(), '@(src|tests)', '**', '*.js' );
-
-for ( const filePath of glob.sync( srcPath ) ) {
-	const fileContent = fs.readFileSync( filePath, 'utf-8' )
-		.replace( /\nimport([^;]+)\.js';/g, '\nimport$1\';' );
-
-	fs.writeFileSync( filePath, fileContent , 'utf-8' );
-}

+ 3 - 0
scripts/switch-to-dev-dev.sh

@@ -3,6 +3,9 @@
 # @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
 # For licensing, see LICENSE.md.
 
+# Symlinks packages from https://github.com/ckeditor/ckeditor5-dev in ckeditor5's node_modules.
+# This allows easily switching to dev versions of ckeditor5-dev-* packages.
+
 set -e
 
 # If it doesn't exist the following lines won't work.

+ 0 - 33
scripts/switch-to-scoped-imports.js

@@ -1,33 +0,0 @@
-#!/usr/bin/env node
-
-'use strict';
-
-const fs = require( 'fs' );
-const path = require( 'path' );
-const glob = require( 'glob' );
-
-const srcPath = path.join( process.cwd(), '@(src|tests)' );
-
-for ( const filePath of glob.sync( path.join( srcPath, '**', '*.js' ) ) ) {
-	let fileContent = fs.readFileSync( filePath, 'utf-8' );
-
-	fileContent = fileContent.replace( /from '(ckeditor5-[\w\-]+)\//g, 'from \'@ckeditor/$1/' );
-	fileContent = fixInnerImports( filePath, fileContent );
-
-	fs.writeFileSync( filePath, fileContent );
-}
-
-// Inner imports should be relative.
-function fixInnerImports( filePath, fileContent ) {
-	const packageName = filePath.match( /ckeditor5-[\w-]+/ )[ 0 ];
-	const relativePath = filePath.replace( /^.+ckeditor5-[\w-]+\//, '' );
-	const depth = relativePath.split( '/' ).length - 1;
-
-	fileContent = fileContent.replace( new RegExp( ` '@ckeditor/${ packageName }/`, 'g' ), () => {
-		const relativePath = '../'.repeat( depth );
-
-		return ` '${ relativePath }`;
-	} );
-
-	return fileContent;
-}