Skip to content

Commit

Permalink
Merge 0d6a1df into a0325a7
Browse files Browse the repository at this point in the history
  • Loading branch information
martnpaneq committed Dec 20, 2022
2 parents a0325a7 + 0d6a1df commit acdae75
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
coverage/
node_modules/
yarn.lock
.idea
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
"license": "MIT",
"homepage": "https://ckeditor.com/ckeditor-5",
"devDependencies": {
"@ckeditor/ckeditor5-dev-docs": "^30.0.0",
"@ckeditor/ckeditor5-dev-env": "^30.0.0",
"@ckeditor/ckeditor5-dev-bump-year": "^32.0.0",
"@ckeditor/ckeditor5-dev-release-tools": "^32.0.0",
"@ckeditor/ckeditor5-dev-web-crawler": "^32.0.0",
"chalk": "^4.1.2",
"eslint": "^7.32.0",
"eslint-config-ckeditor5": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-package-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"node": ">=14.0.0"
},
"dependencies": {
"@ckeditor/ckeditor5-dev-utils": "^30.0.0",
"@ckeditor/ckeditor5-dev-utils": "^32.0.0",
"chalk": "^4.1.2",
"commander": "^8.1.0",
"glob": "^7.1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

const path = require( 'path' );
const glob = require( 'glob' );
const { createPotFiles } = require( '@ckeditor/ckeditor5-dev-transifex' );

module.exports = options => {
// Glob handles posix paths.
const sourceFilesGlob = path.join( options.cwd, 'src', '**', '*.[jt]s' ).split( /[\\/]/g ).join( '/' );

return require( '@ckeditor/ckeditor5-dev-env' ).createPotFiles( {
return createPotFiles( {
// An array containing absolute paths the package sources.
sourceFiles: glob.sync( sourceFilesGlob ),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';

const path = require( 'path' );
const { getToken, downloadTranslations } = require( '@ckeditor/ckeditor5-dev-transifex' );

module.exports = async options => {
if ( !options.organization ) {
Expand All @@ -20,12 +21,10 @@ module.exports = async options => {
throw new Error( 'The --transifex [API end-point] option is no longer supported. Use `--organization` and `--project` instead.' );
}

const getToken = require( '@ckeditor/ckeditor5-dev-env/lib/translations/gettoken' );

const pkgJson = require( path.join( options.cwd, 'package.json' ) );
const packageName = pkgJson.name.split( '/' ).pop();

return require( '@ckeditor/ckeditor5-dev-env' ).downloadTranslations( {
return downloadTranslations( {
// Token used for authentication with the Transifex service.
token: await getToken(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';

const path = require( 'path' );
const { getToken, uploadPotFiles } = require( '@ckeditor/ckeditor5-dev-transifex' );

module.exports = async options => {
if ( !options.organization ) {
Expand All @@ -20,12 +21,10 @@ module.exports = async options => {
throw new Error( 'The --transifex [API end-point] option is no longer supported. Use `--organization` and `--project` instead.' );
}

const getToken = require( '@ckeditor/ckeditor5-dev-env/lib/translations/gettoken' );

const pkgJson = require( path.join( options.cwd, 'package.json' ) );
const packageName = pkgJson.name.split( '/' ).pop();

return require( '@ckeditor/ckeditor5-dev-env' ).uploadPotFiles( {
return uploadPotFiles( {
// Token used for authentication with the Transifex service.
token: await getToken(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const fs = require( 'fs' );

const webpack = require( 'webpack' );
const TerserPlugin = require( 'terser-webpack-plugin' );
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
const { loaderDefinitions } = require( './webpack-utils' );

module.exports = options => {
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = options => {
// include the CKEditor 5 Webpack plugin that produces translation files.
if ( fs.existsSync( path.join( options.cwd, 'lang', 'translations', 'en.po' ) ) ) {
webpackPlugins.push(
new CKEditorWebpackPlugin( {
new CKEditorTranslationsPlugin( {
language: 'en',
additionalLanguages: 'all',
sourceFilesPattern: /^src[/\\].+\.[jt]s$/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const fs = require( 'fs' );
const path = require( 'path' );
const webpack = require( 'webpack' );
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
const { CKEditorTranslationsPlugin } = require( '@ckeditor/ckeditor5-dev-translations' );
const { loaderDefinitions } = require( './webpack-utils' );

module.exports = options => {
Expand All @@ -26,7 +26,7 @@ module.exports = options => {

if ( options.language !== 'en' ) {
webpackPlugins.push(
new CKEditorWebpackPlugin( {
new CKEditorTranslationsPlugin( {
language: options.language,
sourceFilesPattern: /src[/\\].+\.[jt]s$/
} )
Expand Down
8 changes: 4 additions & 4 deletions packages/ckeditor5-package-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
],
"main": "lib/index.js",
"dependencies": {
"@ckeditor/ckeditor5-dev-utils": "^30.0.0",
"@ckeditor/ckeditor5-dev-env": "^30.0.0",
"@ckeditor/ckeditor5-dev-webpack-plugin": "^30.0.0",
"@ckeditor/ckeditor5-dev-transifex": "^32.0.0",
"@ckeditor/ckeditor5-dev-translations": "^32.0.0",
"@ckeditor/ckeditor5-dev-utils": "^32.0.0",
"buffer": "^6.0.3",
"chai": "^4.3.4",
"css-loader": "^5.2.7",
Expand All @@ -30,9 +30,9 @@
"karma-webpack": "^5.0.0",
"minimist": "^1.2.5",
"mocha": "^7.2.0",
"process": "^0.11.10",
"postcss": "^8.4.12",
"postcss-loader": "^4.3.0",
"process": "^0.11.10",
"raw-loader": "^4.0.2",
"sinon": "^9.2.4",
"sinon-chai": "^3.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe( 'lib/tasks/translations-collect', () => {
} );

stubs = {
devEnv: {
transifex: {
createPotFiles: sinon.stub()
},
path: {
Expand All @@ -33,7 +33,7 @@ describe( 'lib/tasks/translations-collect', () => {

mockery.registerMock( 'path', stubs.path );
mockery.registerMock( 'glob', stubs.glob );
mockery.registerMock( '@ckeditor/ckeditor5-dev-env', stubs.devEnv );
mockery.registerMock( '@ckeditor/ckeditor5-dev-transifex', stubs.transifex );

translationsCollect = require( '../../lib/tasks/translations-collect' );
} );
Expand All @@ -54,7 +54,7 @@ describe( 'lib/tasks/translations-collect', () => {
];

stubs.glob.sync.returns( sourceFiles );
stubs.devEnv.createPotFiles.returns( 'OK' );
stubs.transifex.createPotFiles.returns( 'OK' );

const results = translationsCollect( {
cwd: '/workspace'
Expand All @@ -65,8 +65,8 @@ describe( 'lib/tasks/translations-collect', () => {
expect( stubs.glob.sync.calledOnce ).to.equal( true );
expect( stubs.glob.sync.firstCall.firstArg ).to.equal( '/workspace/src/**/*.[jt]s' );

expect( stubs.devEnv.createPotFiles.calledOnce ).to.equal( true );
expect( stubs.devEnv.createPotFiles.firstCall.firstArg ).to.deep.equal( {
expect( stubs.transifex.createPotFiles.calledOnce ).to.equal( true );
expect( stubs.transifex.createPotFiles.firstCall.firstArg ).to.deep.equal( {
// Verify results returned by `glob.sync()`.
sourceFiles,
// Verify a path to the `@ckeditor/ckeditor5-core` package.
Expand All @@ -91,7 +91,7 @@ describe( 'lib/tasks/translations-collect', () => {
];

stubs.glob.sync.returns( sourceFiles );
stubs.devEnv.createPotFiles.returns( 'OK' );
stubs.transifex.createPotFiles.returns( 'OK' );

const results = translationsCollect( {
cwd: '/workspace'
Expand All @@ -102,8 +102,8 @@ describe( 'lib/tasks/translations-collect', () => {
expect( stubs.glob.sync.calledOnce ).to.equal( true );
expect( stubs.glob.sync.firstCall.firstArg ).to.equal( '/workspace/src/**/*.[jt]s' );

expect( stubs.devEnv.createPotFiles.calledOnce ).to.equal( true );
expect( stubs.devEnv.createPotFiles.firstCall.firstArg ).to.deep.equal( {
expect( stubs.transifex.createPotFiles.calledOnce ).to.equal( true );
expect( stubs.transifex.createPotFiles.firstCall.firstArg ).to.deep.equal( {
// Verify results returned by `glob.sync()`.
sourceFiles,
// Verify a path to the `@ckeditor/ckeditor5-core` package.
Expand All @@ -122,7 +122,7 @@ describe( 'lib/tasks/translations-collect', () => {
} );

it( 'passes posix paths to glob', () => {
stubs.devEnv.createPotFiles.returns( 'OK' );
stubs.transifex.createPotFiles.returns( 'OK' );

const results = translationsCollect( {
cwd: 'C:\\workspace'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe( 'lib/tasks/translations-download', () => {
} );

stubs = {
getToken: sinon.stub(),
devEnv: {
transifex: {
getToken: sinon.stub(),
downloadTranslations: sinon.stub()
},
path: {
Expand All @@ -34,8 +34,7 @@ describe( 'lib/tasks/translations-download', () => {
mockery.registerMock( '/workspace/package.json', {
name: '@ckeditor/ckeditor5-foo'
} );
mockery.registerMock( '@ckeditor/ckeditor5-dev-env', stubs.devEnv );
mockery.registerMock( '@ckeditor/ckeditor5-dev-env/lib/translations/gettoken', stubs.getToken );
mockery.registerMock( '@ckeditor/ckeditor5-dev-transifex', stubs.transifex );

translationsDownload = require( '../../lib/tasks/translations-download' );
} );
Expand All @@ -50,8 +49,8 @@ describe( 'lib/tasks/translations-download', () => {
} );

it( 'downloads translation files', async () => {
stubs.getToken.resolves( 'secretToken' );
stubs.devEnv.downloadTranslations.resolves( 'OK' );
stubs.transifex.getToken.resolves( 'secretToken' );
stubs.transifex.downloadTranslations.resolves( 'OK' );

const results = await translationsDownload( {
cwd: '/workspace',
Expand All @@ -61,8 +60,8 @@ describe( 'lib/tasks/translations-download', () => {

expect( results ).to.equal( 'OK' );

expect( stubs.devEnv.downloadTranslations.calledOnce ).to.equal( true );
expect( stubs.devEnv.downloadTranslations.firstCall.firstArg ).to.deep.equal( {
expect( stubs.transifex.downloadTranslations.calledOnce ).to.equal( true );
expect( stubs.transifex.downloadTranslations.firstCall.firstArg ).to.deep.equal( {
token: 'secretToken',
organizationName: 'foo',
projectName: 'bar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe( 'lib/tasks/translations-upload', () => {
} );

stubs = {
getToken: sinon.stub(),
devEnv: {
transifex: {
getToken: sinon.stub(),
uploadPotFiles: sinon.stub()
},
path: {
Expand All @@ -34,8 +34,7 @@ describe( 'lib/tasks/translations-upload', () => {
mockery.registerMock( '/workspace/package.json', {
name: '@ckeditor/ckeditor5-foo'
} );
mockery.registerMock( '@ckeditor/ckeditor5-dev-env', stubs.devEnv );
mockery.registerMock( '@ckeditor/ckeditor5-dev-env/lib/translations/gettoken', stubs.getToken );
mockery.registerMock( '@ckeditor/ckeditor5-dev-transifex', stubs.transifex );

translationsUpload = require( '../../lib/tasks/translations-upload' );
} );
Expand All @@ -50,8 +49,8 @@ describe( 'lib/tasks/translations-upload', () => {
} );

it( 'uploads translation files', async () => {
stubs.getToken.resolves( 'secretToken' );
stubs.devEnv.uploadPotFiles.resolves( 'OK' );
stubs.transifex.getToken.resolves( 'secretToken' );
stubs.transifex.uploadPotFiles.resolves( 'OK' );

const results = await translationsUpload( {
cwd: '/workspace',
Expand All @@ -61,8 +60,8 @@ describe( 'lib/tasks/translations-upload', () => {

expect( results ).to.equal( 'OK' );

expect( stubs.devEnv.uploadPotFiles.calledOnce ).to.equal( true );
expect( stubs.devEnv.uploadPotFiles.firstCall.firstArg ).to.deep.equal( {
expect( stubs.transifex.uploadPotFiles.calledOnce ).to.equal( true );
expect( stubs.transifex.uploadPotFiles.firstCall.firstArg ).to.deep.equal( {
token: 'secretToken',
cwd: '/workspace',
organizationName: 'foo',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe( 'lib/utils/get-webpack-config-dll', () => {
webpack: sinon.stub(),
dllReferencePlugin: sinon.stub(),
providePlugin: sinon.stub(),
devWebpackPlugin: sinon.stub(),
devTranslations: {
CKEditorTranslationsPlugin: sinon.stub()
},
webpackUtils: {
loaderDefinitions: {
raw: sinon.stub(),
Expand Down Expand Up @@ -70,7 +72,7 @@ describe( 'lib/utils/get-webpack-config-dll', () => {
mockery.registerMock( 'path', stubs.path );
mockery.registerMock( 'webpack', stubs.webpack );
mockery.registerMock( './webpack-utils', stubs.webpackUtils );
mockery.registerMock( '@ckeditor/ckeditor5-dev-webpack-plugin', stubs.devWebpackPlugin );
mockery.registerMock( '@ckeditor/ckeditor5-dev-translations', stubs.devTranslations );

mockery.registerMock( '/process/cwd/node_modules/ckeditor5/build/ckeditor5-dll.manifest.json', stubs.ckeditor5manifest );
mockery.registerMock( '/process/cwd/package.json', stubs.packageJson );
Expand Down Expand Up @@ -163,8 +165,8 @@ describe( 'lib/utils/get-webpack-config-dll', () => {
expect( stubs.fs.existsSync.calledOnce ).to.equal( true );
expect( stubs.fs.existsSync.firstCall.firstArg ).to.equal( '/process/cwd/lang/translations/en.po' );

expect( stubs.devWebpackPlugin.calledOnce ).to.equal( true );
expect( stubs.devWebpackPlugin.firstCall.firstArg ).to.deep.equal( {
expect( stubs.devTranslations.CKEditorTranslationsPlugin.calledOnce ).to.equal( true );
expect( stubs.devTranslations.CKEditorTranslationsPlugin.firstCall.firstArg ).to.deep.equal( {
additionalLanguages: 'all',
language: 'en',
skipPluralFormFunction: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ describe( 'lib/utils/get-webpack-config-server', () => {
webpack: sinon.stub(),
providePlugin: sinon.stub(),
definePlugin: sinon.stub(),
devWebpackPlugin: sinon.stub(),
devTranslations: {
CKEditorTranslationsPlugin: sinon.stub()
},
webpackUtils: {
loaderDefinitions: {
raw: sinon.stub(),
Expand Down Expand Up @@ -67,7 +69,7 @@ describe( 'lib/utils/get-webpack-config-server', () => {
mockery.registerMock( 'path', stubs.path );
mockery.registerMock( 'webpack', stubs.webpack );
mockery.registerMock( './webpack-utils', stubs.webpackUtils );
mockery.registerMock( '@ckeditor/ckeditor5-dev-webpack-plugin', stubs.devWebpackPlugin );
mockery.registerMock( '@ckeditor/ckeditor5-dev-translations', stubs.devTranslations );

getWebpackConfigServer = require( '../../lib/utils/get-webpack-config-server' );
} );
Expand Down Expand Up @@ -181,8 +183,8 @@ describe( 'lib/utils/get-webpack-config-server', () => {
EDITOR_LANGUAGE: '"pl"'
} );

expect( stubs.devWebpackPlugin.calledOnce ).to.equal( true );
expect( stubs.devWebpackPlugin.firstCall.firstArg ).to.deep.equal( {
expect( stubs.devTranslations.CKEditorTranslationsPlugin.calledOnce ).to.equal( true );
expect( stubs.devTranslations.CKEditorTranslationsPlugin.firstCall.firstArg ).to.deep.equal( {
language: 'pl',
sourceFilesPattern: /src[/\\].+\.[jt]s$/
} );
Expand Down
2 changes: 1 addition & 1 deletion scripts/bump-year.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ git commit -am "Internal: Bumped the year." && git push
*/

require( '@ckeditor/ckeditor5-dev-env' )
require( '@ckeditor/ckeditor5-dev-bump-year' )
.bumpYear( {
cwd: process.cwd(),
globPatterns: [
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/verify-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

const crawler = require( '@ckeditor/ckeditor5-dev-docs/lib/web-crawler/index.js' );
const { runCrawler } = require( '@ckeditor/ckeditor5-dev-web-crawler' );

// The crawler uses `process.exit()` to finish its work, so it needs to be executed in
// a separated process to avoid canceling a build if the verification is in the middle of tasks
Expand All @@ -21,7 +21,7 @@ const crawler = require( '@ckeditor/ckeditor5-dev-docs/lib/web-crawler/index.js'
// [1] = './verify-sample.js'
// [2] = 'http://localhost:8080/'

crawler( {
runCrawler( {
url: process.argv[ 2 ],
depth: 1,
concurrency: 1,
Expand Down
2 changes: 1 addition & 1 deletion scripts/release/bump-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Use:
// yarn run release:bump-version --dry-run

require( '@ckeditor/ckeditor5-dev-env' )
require( '@ckeditor/ckeditor5-dev-release-tools' )
.bumpVersions( {
cwd: process.cwd(),
packages: 'packages',
Expand Down

0 comments on commit acdae75

Please sign in to comment.