forked from carbon-design-system/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for elements migration (#2)
feat/add-elements-migration
- Loading branch information
Showing
54 changed files
with
1,365 additions
and
199 deletions.
There are no files selected for viewing
Binary file added
BIN
+14.1 KB
packages/upgrade/.yarn-offline-mirror/@mrmlnc-readdir-enhanced-2.2.1.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.selector { | ||
color: $ibm-colors__blue--50; | ||
} | ||
|
||
.animated { | ||
transition-timing-function: map-get($easings, productive); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"@carbon/colors": "0.0.1-alpha.27" | ||
"@carbon/colors": "0.0.1-alpha.27", | ||
"@carbon/motion": "0.0.1-alpha.27", | ||
"carbon-components": "9.x" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright IBM Corp. 2019, 2019 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
reporter: { | ||
error: jest.fn(), | ||
header: jest.fn(), | ||
info: jest.fn(), | ||
log: jest.fn(), | ||
setLogLevel: jest.fn(), | ||
stack: jest.fn(), | ||
success: jest.fn(), | ||
verbose: jest.fn(), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* Copyright IBM Corp. 2019, 2019 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const cli = require('yargs'); | ||
const packageJson = require('../package.json'); | ||
const { UpgradeError } = require('./error'); | ||
const { reporter } = require('./reporter'); | ||
const { run, runInDirectory } = require('./runner'); | ||
|
||
async function main({ argv, cwd }) { | ||
cli.scriptName(packageJson.name).version(packageJson.version); | ||
|
||
cli | ||
.option('verbose', { | ||
default: false, | ||
describe: 'display the full output while running a command', | ||
}) | ||
.option('dry', { | ||
alias: 'd', | ||
describe: | ||
'view the result of running this command without changing any files', | ||
default: false, | ||
}) | ||
.option('ignore', { | ||
alias: 'i', | ||
describe: 'provide a glob pattern for directories you would like ignored', | ||
default: '', | ||
}); | ||
|
||
cli | ||
.usage('Usage: $0 [options]') | ||
.command('$0', 'run to upgrade your project', {}, async args => { | ||
const { dry, ignore, verbose } = args; | ||
const options = { | ||
cwd: cwd(), | ||
dry, | ||
ignore, | ||
verbose, | ||
}; | ||
|
||
await runCommand(() => runInDirectory(options), options); | ||
}); | ||
|
||
cli.command( | ||
'migrate <package> <from> <to>', | ||
'run a specific migration for a package', | ||
{}, | ||
async args => { | ||
const { dry, from, ignore, package: packageName, to, verbose } = args; | ||
const options = { | ||
cwd: cwd(), | ||
dry, | ||
ignore, | ||
verbose, | ||
}; | ||
|
||
await runCommand(() => run(packageName, from, to, options), options); | ||
} | ||
); | ||
|
||
cli | ||
.demandCommand() | ||
.recommendCommands() | ||
.strict() | ||
.parse(argv.slice(2)).argv; | ||
} | ||
|
||
async function runCommand(makePromise, options) { | ||
reporter.info('Thanks for trying out carbon-upgrade! 🙏'); | ||
reporter.info( | ||
'To help prevent any accidental changes, make sure to check in your ' + | ||
'work in version control first and use dry mode (-d flag) to ' + | ||
'preview any updates!' | ||
); | ||
|
||
if (options.verbose) { | ||
reporter.setLogLevel('verbose'); | ||
} | ||
|
||
try { | ||
const start = Date.now(); | ||
await makePromise(); | ||
console.log(`✨ Done in ${Date.now() - start}ms`); | ||
} catch (error) { | ||
if (error instanceof UpgradeError) { | ||
reporter.error(error.message); | ||
return; | ||
} | ||
reporter.error('Yikes, looks like something really went wrong.'); | ||
reporter.error('Please make an issue with the following info:'); | ||
console.log(error); | ||
} | ||
} | ||
|
||
module.exports = main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
packages/upgrade/src/migrations/carbon-colors/0.0.1-alpha.28.js
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
packages/upgrade/src/migrations/carbon-colors/0.0.1-alpha.31.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright IBM Corp. 2019, 2019 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { reporter } = require('../../reporter'); | ||
const { replace } = require('../../tools/replace'); | ||
|
||
const TARGET_VERSION = '0.0.1-alpha.31'; | ||
|
||
module.exports = { | ||
version: TARGET_VERSION, | ||
from: [ | ||
{ | ||
version: '<=0.0.1-alpha.30', | ||
async migrate(options) { | ||
const changes = [ | ||
{ | ||
from: /(\$ibm-colors__[a-z]+)(--)([\d]+)/gm, | ||
// Capture group $1 refers to $ibm-colors__abcd | ||
// $2 refers to double dash (--) | ||
// $3 is the grade at the end | ||
to: '$1-$3', | ||
}, | ||
]; | ||
|
||
await replace('**/*.scss', changes, options); | ||
}, | ||
}, | ||
], | ||
}; |
29 changes: 29 additions & 0 deletions
29
packages/upgrade/src/migrations/carbon-colors/__tests__/0.0.1-alpha.31.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright IBM Corp. 2019, 2019 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @jest-environment node | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { defineInlineTest } = require('../../../tools/testing'); | ||
|
||
defineInlineTest( | ||
require.resolve('../0.0.1-alpha.31.js'), | ||
'0.0.1-alpha.30', | ||
` | ||
$ibm-colors__blue--50; | ||
$ibm-colors__teal--50; | ||
color: $ibm-colors__blue--50; | ||
color: $ibm-colors__teal--50; | ||
`, | ||
` | ||
$ibm-colors__blue-50; | ||
$ibm-colors__teal-50; | ||
color: $ibm-colors__blue-50; | ||
color: $ibm-colors__teal-50; | ||
` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/upgrade/src/migrations/carbon-elements/0.0.1-alpha.31.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright IBM Corp. 2019, 2019 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { reporter } = require('../../reporter'); | ||
const colors = require('../carbon-colors/0.0.1-alpha.31'); | ||
const grid = require('../carbon-grid/0.0.1-alpha.31'); | ||
const layout = require('../carbon-layout/0.0.1-alpha.31'); | ||
const motion = require('../carbon-motion/0.0.1-alpha.31'); | ||
|
||
const TARGET_VERSION = '0.0.1-alpha.31'; | ||
|
||
module.exports = { | ||
version: TARGET_VERSION, | ||
from: [ | ||
{ | ||
version: '<=0.0.1-alpha.30', | ||
async migrate(options) { | ||
const migrations = [ | ||
...colors.from, | ||
...grid.from, | ||
...layout.from, | ||
...motion.from, | ||
].filter(({ version }) => version === '<=0.0.1-alpha.30'); | ||
await Promise.all( | ||
migrations.map(migration => migration.migrate(options)) | ||
); | ||
}, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.