Skip to content

Commit

Permalink
Merge pull request #526 from ckeditor/t/mgit2/85
Browse files Browse the repository at this point in the history
Other: Adjusted repository, documentation and scripts to changes done in mgit/mrgit. See: cksource/mrgit#85.
  • Loading branch information
Reinmar authored Jul 23, 2019
2 parents 4a419ef + 9d91257 commit 8b4d08d
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ module.exports = function releaseSubRepositories( options ) {

if ( !shouldRemove ) {
logDryRun( 'You can remove these files manually by calling `git clean -f` command.' );
logDryRun( 'It will also work using mgit: `mgit exec "git clean -f"`' );
logDryRun( 'It will also work using mrgit: `mrgit exec "git clean -f"`' );

return;
}
Expand Down
14 changes: 7 additions & 7 deletions packages/ckeditor5-dev-tests/bin/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ TEST_DIR=$(mktemp -d)
# Path to the executable in the testing environment.
TEST_BIN=${TEST_DIR}/node_modules/.bin

# Creates required files for Mgit and Yarn.
# Creates required files for mrgit and yarn.
echo '{}' > ${TEST_DIR}/package.json
echo '{}' > ${TEST_DIR}/mgit.json
echo '{}' > ${TEST_DIR}/mrgit.json
mkdir ${TEST_DIR}/packages

# Prepare `package.json`. It creates a "temporary" package.
${ROOT_BIN}/ckeditor5-dev-tests-prepare-package-json ${PACKAGE_ROOT} ${TEST_DIR}

# Prepare `mgit.json`.
${ROOT_BIN}/ckeditor5-dev-tests-prepare-mgit-json ${TEST_DIR}
# Prepare `mrgit.json`.
${ROOT_BIN}/ckeditor5-dev-tests-prepare-mrgit-json ${TEST_DIR}

# Install Mgit.
cd ${TEST_DIR} && yarn add mgit2 --ignore-workspace-root-check
# Install mrgit.
cd ${TEST_DIR} && yarn add mrgit --ignore-workspace-root-check

# Clones repositories to `packages/` directory.
cd ${TEST_DIR} && ${TEST_BIN}/mgit sync --recursive --resolver-path=${PACKAGE_ROOT}/node_modules/@ckeditor/ckeditor5-dev-tests/lib/mgit-resolver.js
cd ${TEST_DIR} && ${TEST_BIN}/mrgit sync --recursive --resolver-path=${PACKAGE_ROOT}/node_modules/@ckeditor/ckeditor5-dev-tests/lib/mrgit-resolver.js

# We need to ignore the newly created packages dir with all its content (see #203).
cd ${TEST_DIR} && echo -e "\npackages/**\n" >> .gitignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ if ( !TEST_DIR_PATH ) {
}

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

tools.updateJSONFile( path.join( TEST_DIR_PATH, 'mgit.json' ), () => {
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 createMgitJsonContent( testingPackageJson, {
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
Expand Down
8 changes: 4 additions & 4 deletions packages/ckeditor5-dev-tests/bin/save-revision.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ process.chdir( path.join( process.cwd(), 'ckeditor5' ) );
// And check out to the revision branch.
exec( `git checkout ${ revisionBranch } ` );

// Install Mgit.
exec( 'npm install -g mgit2' );
// Install Mr. Git.
exec( 'npm install -g mrgit' );

// Sync the revision branch with the master.
exec( `git checkout ${ branch } -- .` );
Expand All @@ -40,10 +40,10 @@ exec( `git checkout ${ branch } -- .` );
exec( 'git reset -q .' );

// Install dependencies.
exec( 'mgit sync --recursive --resolver-url-template="https://github.com/\\${ path }.git"' );
exec( 'mrgit sync --recursive --resolver-url-template="https://github.com/\\${ path }.git"' );

// Save hashes from all dependencies.
exec( 'mgit save --hash' );
exec( 'mrgit save --hash' );

// Add all files (perhaps the changes from master will be committed).
exec( 'git add .' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*/

/**
* Creates content for the `mgit.json` file based on the `package.json` dependencies.
* Creates content for the `mrgit.json` file based on the `package.json` dependencies.
*
* @param {Object} packageJson Parsed package.json.
* @param {Object} [options]
* @param {String} options.name The name of package that `options.commit` will be specified as a version to check out.
* @param {String} options.commit The specified commit.
*/
module.exports = function createMgitJsonContent( packageJson, options ) {
const mgitJson = {
module.exports = function createMrGitJsonContent( packageJson, options ) {
const mrgitJson = {
packages: 'packages/',
dependencies: {}
};
Expand All @@ -34,23 +34,23 @@ module.exports = function createMgitJsonContent( packageJson, options ) {
}

if ( isHashedDependency( dependencyVersion ) ) {
mgitJson.dependencies[ dependencyName ] = dependencyVersion;
mrgitJson.dependencies[ dependencyName ] = dependencyVersion;
} else {
// Removes '@' from the scoped npm package name.
mgitJson.dependencies[ dependencyName ] = dependencyName.slice( 1 );
mrgitJson.dependencies[ dependencyName ] = dependencyName.slice( 1 );
}
}

if ( !options ) {
return mgitJson;
return mrgitJson;
}

// For testing package we need to use a specified commit instead of the latest master.
if ( mgitJson.dependencies[ options.packageName ] ) {
mgitJson.dependencies[ options.packageName ] = mgitJson.dependencies[ options.packageName ] + '#' + options.commit;
if ( mrgitJson.dependencies[ options.packageName ] ) {
mrgitJson.dependencies[ options.packageName ] = mrgitJson.dependencies[ options.packageName ] + '#' + options.commit;
}

return mgitJson;
return mrgitJson;
};

function isHashedDependency( dependency ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'use strict';

const parseRepositoryUrl = require( 'mgit2/lib/utils/parserepositoryurl' );
const parseRepositoryUrl = require( 'mrgit/lib/utils/parserepositoryurl' );

/**
* Resolves repository URL for a given package name.
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-dev-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.5",
"lodash": "^4.17.11",
"mgit2": "^0.10.0",
"mrgit": "^1.0.0",
"minimatch": "^3.0.4",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
Expand Down Expand Up @@ -63,7 +63,7 @@
"ckeditor5-dev-tests": "./bin/test.js",
"ckeditor5-dev-tests-manual": "./bin/test-manual.js",
"ckeditor5-dev-tests-travis": "./bin/test-travis.sh",
"ckeditor5-dev-tests-prepare-mgit-json": "./bin/prepare-mgit-json.js",
"ckeditor5-dev-tests-prepare-mrgit-json": "./bin/prepare-mrgit-json.js",
"ckeditor5-dev-tests-prepare-package-json": "./bin/prepare-package-json.js",
"ckeditor5-dev-tests-install-dependencies": "./bin/install-dependencies.sh",
"ckeditor5-dev-tests-save-revision": "./bin/save-revision.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@

const { expect } = require( 'chai' );

describe( 'dev-tests/bin/create-mgit-json', () => {
let createMgitJson;
describe( 'dev-tests/bin/create-mrgit-json', () => {
let createMrGitJsonContent;

beforeEach( () => {
createMgitJson = require( '../../lib/bin/createmgitjsoncontent' );
createMrGitJsonContent = require( '../../lib/bin/createmrgitjsoncontent' );
} );

it( 'should return a valid mgit config when no dependency in package.json present', () => {
const mgitJson = createMgitJson( {} );
it( 'should return a valid mrgit config when no dependency in package.json present', () => {
const mrgitJson = createMrGitJsonContent( {} );

expect( mgitJson ).to.deep.equal( { dependencies: {}, packages: 'packages/' } );
expect( mrgitJson ).to.deep.equal( { dependencies: {}, packages: 'packages/' } );
} );

it( 'should return an object with dependency names for npm versions of dependencies', () => {
const mgitJson = createMgitJson( {
const mrgitJson = createMrGitJsonContent( {
dependencies: {
'@ckeditor/ckeditor5-core': '^0.8.1',
'@ckeditor/ckeditor5-engine': '0.10.0'
Expand All @@ -31,7 +31,7 @@ describe( 'dev-tests/bin/create-mgit-json', () => {
}
} );

expect( mgitJson ).to.deep.equal( {
expect( mrgitJson ).to.deep.equal( {
dependencies: {
'@ckeditor/ckeditor5-core': 'ckeditor/ckeditor5-core',
'@ckeditor/ckeditor5-engine': 'ckeditor/ckeditor5-engine',
Expand All @@ -42,7 +42,7 @@ describe( 'dev-tests/bin/create-mgit-json', () => {
} );

it( 'should return an object with hashed dependency versions for hashed github versions of dependencies', () => {
const mgitJson = createMgitJson( {
const mrgitJson = createMrGitJsonContent( {
dependencies: {
'@ckeditor/ckeditor5-core': 'ckeditor/ckeditor5-core#1ca5608',
'ckeditor5-some-package': 'git@github.com:cksource/ckeditor5-some-package.git#1234567',
Expand All @@ -53,7 +53,7 @@ describe( 'dev-tests/bin/create-mgit-json', () => {
}
} );

expect( mgitJson ).to.deep.equal( {
expect( mrgitJson ).to.deep.equal( {
dependencies: {
'@ckeditor/ckeditor5-core': 'ckeditor/ckeditor5-core#1ca5608',
'@ckeditor/ckeditor5-paragraph': 'ckeditor/ckeditor5-paragraph#a171de3',
Expand All @@ -65,7 +65,7 @@ describe( 'dev-tests/bin/create-mgit-json', () => {
} );

it( 'should filter out all non "ckeditor5-*" and all "ckeditor5-dev-*" packages', () => {
const mgitJson = createMgitJson( {
const mrgitJson = createMrGitJsonContent( {
dependencies: {
'@scope/package1': 'abc/def#1ca5608',
'@scope/package2': '^1.1.1',
Expand All @@ -76,14 +76,14 @@ describe( 'dev-tests/bin/create-mgit-json', () => {
}
} );

expect( mgitJson ).to.deep.equal( {
expect( mrgitJson ).to.deep.equal( {
dependencies: {},
packages: 'packages/'
} );
} );

it( 'modifies version of specified package (it sets proper commit)', () => {
const mgitJson = createMgitJson( {
const mrgitJson = createMrGitJsonContent( {
dependencies: {
'@ckeditor/ckeditor5-core': '^0.8.1',
'@ckeditor/ckeditor5-engine': '0.10.0'
Expand All @@ -96,7 +96,7 @@ describe( 'dev-tests/bin/create-mgit-json', () => {
commit: 'abcd1234'
} );

expect( mgitJson ).to.deep.equal( {
expect( mrgitJson ).to.deep.equal( {
dependencies: {
'@ckeditor/ckeditor5-core': 'ckeditor/ckeditor5-core#abcd1234',
'@ckeditor/ckeditor5-engine': 'ckeditor/ckeditor5-engine',
Expand Down

0 comments on commit 8b4d08d

Please sign in to comment.