How to use the @ckeditor/ckeditor5-dev-utils.tools.updateJSONFile function in @ckeditor/ckeditor5-dev-utils

To help you get started, we’ve selected a few @ckeditor/ckeditor5-dev-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / bin / prepare-mrgit-json.js View on Github external
* For licensing, see LICENSE.md.
 */

'use strict';

const TEST_DIR_PATH = process.argv[ 2 ];

if ( !TEST_DIR_PATH ) {
	throw new Error( 'The script requires one parameter: a path to the testing directory.' );
}

const path = require( 'path' );
const createMrGitJsonContent = require( '../lib/bin/createmrgitjsoncontent' );
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );

tools.updateJSONFile( path.join( TEST_DIR_PATH, 'mrgit.json' ), () => {
	const originalPackageJson = require( path.join( process.cwd(), 'package.json' ) );
	const testingPackageJson = require( path.join( TEST_DIR_PATH, 'package.json' ) );

	return createMrGitJsonContent( testingPackageJson, {
		packageName: originalPackageJson.name,
		// For PR build we want to get the latest commit from given PR instead of Merge Commit.
		// See: https://github.com/ckeditor/ckeditor5-dev/issues/484
		commit: process.env.TRAVIS_PULL_REQUEST_SHA || process.env.TRAVIS_COMMIT,
		// Specify a repository that provides the package specified as `packageName` and which should be cloned.
		// Forked repositories should be able to execute the test scenario as well.
		// See: https://github.com/ckeditor/ckeditor5-dev/issues/542.
		repository: process.env.TRAVIS_PULL_REQUEST_SLUG || process.env.TRAVIS_REPO_SLUG
	} );
} );
github ckeditor / ckeditor5-react / scripts / release.js View on Github external
.then( version => {
		log.info( 'Restoring the package.json template...' );

		// Restore the template `package.json` to state before the publishing process.
		tools.updateJSONFile( packageJsonTemplatePath, () => packageJsonTemplateCopy );

		const url = `https://github.com/ckeditor/ckeditor5-react/releases/tag/v${ version }`;
		log.info( `Created the release: ${ url }` );
	} )
	.catch( err => {
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / tasks / install / index.js View on Github external
if ( urlInfo.branch ) {
			log.info( `Checking ${ urlInfo.name } to ${ urlInfo.branch }...` );
			git.checkout( repositoryPath, urlInfo.branch );
		}

		// Run `npm install` in new repository.
		log.info( `Running "npm install" in ${ urlInfo.name }...` );
		tools.npmInstall( repositoryPath );

		const linkPath = path.join( ckeditor5Path, 'node_modules', urlInfo.name );

		log.info( `Linking ${ linkPath } to ${ repositoryPath }...` );
		tools.linkDirectories( repositoryPath, linkPath );

		log.info( `Adding ${ urlInfo.name } dependency to CKEditor5 package.json...` );
		tools.updateJSONFile( path.join( ckeditor5Path, 'package.json' ), ( json ) => {
			json.dependencies = json.dependencies || {};
			json.dependencies[ urlInfo.name ] = dependency;
			json.dependencies = tools.sortObject( json.dependencies );

			return json;
		} );
	} else {
		throw new Error( 'Please provide valid GitHub URL, NPM module name or path.' );
	}
};
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / bin / add-workspace-to-package-json.js View on Github external
#!/usr/bin/env node

/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const path = require( 'path' );
const cwd = process.cwd();
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );

tools.updateJSONFile( path.join( cwd, 'package.json' ), json => {
	json.private = true;
	json.workspaces = [
		'*',
		'packages/*'
	];

	return json;
} );
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-tests / bin / prepare-package-json.js View on Github external
*/

'use strict';

const PACKAGE_PATH = process.argv[ 2 ];
const TEST_DIR_PATH = process.argv[ 3 ];

if ( !PACKAGE_PATH || !TEST_DIR_PATH ) {
	throw new Error( 'The script requires two parameters: a path to the package and a path to the testing directory.' );
}

const path = require( 'path' );
const { tools } = require( '@ckeditor/ckeditor5-dev-utils' );
const packageJson = require( path.join( PACKAGE_PATH, 'package.json' ) );

tools.updateJSONFile( path.join( TEST_DIR_PATH, 'package.json' ), () => {
	const json = {
		name: 'ckeditor5-dev-testing-environment',
		version: '0.0.1',
		description: 'This package is a temporary package used for preparing the testing environment. It is used only for CI.',
		dependencies: packageJson.dependencies,
		devDependencies: packageJson.devDependencies,
		engines: packageJson.engines,
		author: packageJson.author,
		license: packageJson.license,
		homepage: packageJson.homepage,
		repository: packageJson.repository,
		scripts: packageJson.scripts,
		eslintIgnore: packageJson.eslintIgnore,
		private: true,
		workspaces: [
			'packages/*'
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / tasks / create-package / index.js View on Github external
);
			}

			log.info( `Updating package.json files...` );
			tools.updateJSONFile( path.join( repositoryPath, 'package.json' ), ( json ) => {
				json.name = packageName;
				json.version = packageVersion;
				json.description = packageDescription;

				return json;
			} );

			log.info( `Running npm install in ${ packageName }.` );
			tools.shExec( `cd ${ repositoryPath } && npm i --save-dev @ckeditor/ckeditor5-dev-lint gulp guppy-pre-commit` );

			tools.updateJSONFile( path.join( ckeditor5Path, 'package.json' ), ( json ) => {
				if ( !json.dependencies ) {
					json.dependencies = {};
				}
				json.dependencies[ packageName ] = gitHubPath;
				json.dependencies = tools.sortObject( json.dependencies );

				return json;
			} );

			log.info( `Creating initial commit...` );
			git.initialCommit( packageName, repositoryPath );

			log.info( `Linking ${ packageName } to node_modules...` );
			tools.linkDirectories( repositoryPath, path.join( ckeditor5Path, 'node_modules', packageName ) );
		} );
};
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / tasks / exec / functions / remove-use-strict.js View on Github external
dir => {
			const jshintrcPath = path.join( workdir, dir, '.jshintrc' );

			tools.updateJSONFile( jshintrcPath, json => {
				json.strict = 'implied';

				return json;
			} );
		}
	);
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / tasks / exec / functions / remove-use-strict.js View on Github external
function reformatOtherConfigs( workdir ) {
	tools.updateJSONFile( path.join( workdir, 'dev', '.jshintrc' ), json => json );
	tools.updateJSONFile( path.join( workdir, '.jscsrc' ), json => json );
}
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / release-tools / utils / updatedependenciesversions.js View on Github external
module.exports = function updateDependenciesVersions( dependencies, packageJsonPath ) {
	tools.updateJSONFile( packageJsonPath, json => {
		for ( const item of dependencies.keys() ) {
			const version = dependencies.get( item );

			if ( json.dependencies && json.dependencies[ item ] ) {
				json.dependencies[ item ] = `^${ version }`;
			} else if ( json.devDependencies && json.devDependencies[ item ] ) {
				json.devDependencies[ item ] = `^${ version }`;
			} else if ( json.peerDependencies && json.peerDependencies[ item ] ) {
				json.peerDependencies[ item ] = version;
			}
		}

		return json;
	} );
};
github ckeditor / ckeditor5-dev / packages / ckeditor5-dev-env / lib / tasks / exec / functions / remove-use-strict.js View on Github external
function reformatOtherConfigs( workdir ) {
	tools.updateJSONFile( path.join( workdir, 'dev', '.jshintrc' ), json => json );
	tools.updateJSONFile( path.join( workdir, '.jscsrc' ), json => json );
}