forked from tinymce/tinymce
-
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.
Initial config of lerna and top level workspace, composite tsconfigs,…
… readme
- Loading branch information
Showing
37 changed files
with
1,038 additions
and
228 deletions.
There are no files selected for viewing
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,8 +1,10 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
end_of_line = lf |
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 |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
*.flv binary | ||
*.rm binary | ||
*.dcr binary | ||
*.sketch binary |
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,13 @@ | ||
.DS_Store | ||
*~ | ||
*.iws | ||
*.sublime-workspace | ||
node_modules | ||
|
||
package-lock.json | ||
yarn-error.log* | ||
lerna-debug.log | ||
scratch | ||
lib | ||
tsconfig.tsbuildinfo | ||
modules/*/LICENSE.TXT |
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,50 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
// We don't always upgrade typescript immediately, this helps avoid errors when vscode is ahead | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
|
||
"files.exclude": { | ||
// start by ignoring _most_ of node_modules | ||
"node_modules/[a-zA-Z]*": true, | ||
"node_modules/@babel": true, | ||
"node_modules/@gulp-sourcemaps": true, | ||
"node_modules/@lerna": true, | ||
"node_modules/@mrmlnc": true, | ||
"node_modules/@nodelib": true, | ||
"node_modules/@octokit": true, | ||
"node_modules/@types": true, | ||
"node_modules/@webassemblyjs": true, | ||
"node_modules/@xtuc": true, | ||
|
||
// ignore monorepo packages symlinked into node_modules | ||
"node_modules/@ephox/acid": true, | ||
"node_modules/@ephox/agar": true, | ||
"node_modules/@ephox/alloy": true, | ||
"node_modules/@ephox/boss": true, | ||
"node_modules/@ephox/boulder": true, | ||
"node_modules/@ephox/bridge": true, | ||
"node_modules/@ephox/darwin": true, | ||
"node_modules/@ephox/dragster": true, | ||
"node_modules/@ephox/echo": true, | ||
"node_modules/@ephox/imagetools": true, | ||
"node_modules/@ephox/jax": true, | ||
"node_modules/@ephox/katamari": true, | ||
"node_modules/@ephox/mcagar": true, | ||
"node_modules/@tinymce/oxide": true, | ||
"node_modules/@tinymce/oxide-icons-default": true, | ||
"node_modules/@ephox/phoenix": true, | ||
"node_modules/@ephox/polaris": true, | ||
"node_modules/@ephox/porkbun": true, | ||
"node_modules/@ephox/robin": true, | ||
"node_modules/@ephox/sand": true, | ||
"node_modules/@ephox/snooker": true, | ||
"node_modules/@ephox/sugar": true, | ||
"node_modules/@ephox/tinymce": true, | ||
|
||
// ignore oxide build output | ||
"modules/oxide/build": true, | ||
"modules/oxide-icons-default/dist": true, | ||
"modules/tinymce/js": true, | ||
"modules/*/lib": true, | ||
} | ||
} |
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,210 @@ | ||
const runsInPhantom = [ | ||
'@ephox/acid', | ||
'@ephox/alloy', | ||
'@ephox/boss', | ||
'@ephox/boulder', | ||
'@ephox/dragster', | ||
'@ephox/echo', | ||
'@ephox/imagetools', | ||
'@ephox/jax', | ||
'@ephox/katamari', | ||
'@ephox/mcagar', | ||
'@ephox/polaris', | ||
'@ephox/porkbun', | ||
'@ephox/robin', | ||
'@ephox/snooker', | ||
]; | ||
|
||
const needsTinyMCE = ['@ephox/mcagar']; | ||
|
||
const runsInBrowser = [ | ||
'@ephox/agar', | ||
'@ephox/bridge', | ||
'@ephox/darwin', | ||
'@ephox/phoenix', | ||
'@ephox/sand', | ||
'@ephox/sugar', | ||
'tinymce', | ||
]; | ||
|
||
if (!Array.prototype.flatMap) { | ||
// simple polyfill for node versions < 11 | ||
// not at all to ES2019 spec, but if you're relying on that you should use node 11 /shrug | ||
const concat = (x, y) => x.concat(y); | ||
|
||
const flatMap = (f, xs) => xs.map(f).reduce(concat, []); | ||
|
||
Array.prototype.flatMap = function (f) { | ||
return flatMap(f, this); | ||
}; | ||
} | ||
|
||
const filterChanges = (changes, tests) => { | ||
return changes.filter((change => tests.indexOf(change.name) > -1)); | ||
}; | ||
|
||
/* structure of lerna output | ||
{ | ||
name: string, | ||
version: string, | ||
private: boolean, | ||
location: string | ||
} | ||
*/ | ||
|
||
const testFolders = (tests, auto) => tests.flatMap(({location}) => [ | ||
`${location}/**/test/**/atomic/**/*Test.ts`, | ||
`${location}/**/test/**/browser/**/*Test.ts`, | ||
`${location}/**/test/**/phantom/**/*Test.ts`, | ||
].concat(auto ? `${location}/**/test/**/webdriver/**/*Test.ts` : [])); | ||
|
||
const bedrockDefaults = { | ||
config: 'tsconfig.json', | ||
overallTimeout: 180000, | ||
singleTimeout: 60000, | ||
}; | ||
|
||
const bedrockPhantom = (tests) => { | ||
if (tests.length === 0) { | ||
return {}; | ||
} else { | ||
return { | ||
phantomjs: { | ||
...bedrockDefaults, | ||
name: 'phantom-tests', | ||
browser: 'phantomjs', | ||
testfiles: testFolders(tests, true), | ||
customRoutes: 'modules/jax/src/test/json/routes.json', | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const bedrockBrowser = (tests, browserName, osName, auto) => { | ||
if (tests.length === 0) { | ||
return {}; | ||
} else { | ||
return { | ||
browser: { | ||
...bedrockDefaults, | ||
overallTimeout: 900000, | ||
name: `${browserName}-${osName}`, | ||
browser: browserName, | ||
testfiles: testFolders(tests, auto), | ||
customRoutes: 'modules/tinymce/src/core/test/json/routes.json', | ||
|
||
// we have a few tests that don't play nicely when combined together in the monorepo | ||
retries: 3 | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const fetchLernaProjects = (log, runAllTests) => { | ||
// This has to be sync because grunt can't do async config | ||
var exec = require('child_process').execSync; | ||
|
||
// if JSON parse fails, well, grunt will just fail /shrug | ||
const parseLernaList = (cmd) => { | ||
try { | ||
return JSON.parse(exec(`yarn -s lerna ${cmd} -a --no-ignore-changes --json --loglevel warn 2>&1`)); | ||
} catch (e) { | ||
// If no changes are found, then lerna returns an exit code of 1, so deal with that gracefully | ||
if (e.status === 1) { | ||
return []; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
}; | ||
|
||
const changes = runAllTests ? [] : parseLernaList('changed'); | ||
|
||
if (changes.length === 0) { | ||
log.writeln('No changes found, testing all projects'); | ||
// If there are no changes, use "lerna list" instead of "lerna changed" to test everything | ||
return parseLernaList('list'); | ||
} else { | ||
return changes; | ||
} | ||
|
||
}; | ||
|
||
module.exports = function (grunt) { | ||
const runAllTests = grunt.option('ignore-lerna-changed') || false; | ||
const changes = fetchLernaProjects(grunt.log, runAllTests); | ||
|
||
const phantomTests = filterChanges(changes, runsInPhantom); | ||
const browserTests = filterChanges(changes, runsInBrowser); | ||
|
||
const activeBrowser = grunt.option('bedrock-browser') || 'chrome-headless'; | ||
const activeOs = grunt.option('bedrock-os') || 'tests'; | ||
const bedrockPhantomConfig = bedrockPhantom(phantomTests); | ||
const gruntConfig = { | ||
shell: { | ||
tsc: { command: 'yarn -s tsc' }, | ||
rollup: { command: 'yarn -s tinymce-rollup' }, | ||
yarn: { command: 'yarn' }, | ||
'yarn-dev': { command: 'yarn -s dev' } | ||
}, | ||
'bedrock-auto': { | ||
...bedrockPhantomConfig, | ||
...bedrockBrowser(browserTests, activeBrowser, activeOs, true) | ||
}, | ||
'bedrock-manual': { | ||
...bedrockPhantomConfig, | ||
...bedrockBrowser(browserTests, activeBrowser, activeOs, false) | ||
} | ||
}; | ||
|
||
// console.log(JSON.stringify(gruntConfig, null, 2)) | ||
|
||
grunt.initConfig(gruntConfig); | ||
|
||
//dupe de dupe dupe | ||
if (phantomTests.length > 0) { | ||
grunt.registerTask('list-changed-phantom', () => { | ||
const changeList = JSON.stringify(phantomTests.reduce((acc, change) => acc.concat(change.name), []), null, 2); | ||
grunt.log.writeln('Changed projects for phantomjs testing:', changeList); | ||
}); | ||
if (phantomTests.find(({name}) => needsTinyMCE.indexOf(name) > -1)) { | ||
// only run rollup if required, since it's quite slow | ||
grunt.registerTask('phantomjs-auto', ['shell:rollup', 'list-changed-phantom', 'shell:tsc', 'bedrock-auto:phantomjs']); | ||
} else { | ||
grunt.registerTask('phantomjs-auto', ['list-changed-phantom', 'shell:tsc', 'bedrock-auto:phantomjs']); | ||
} | ||
grunt.registerTask('phantomjs-manual', ['shell:tsc', 'bedrock-manual:phantomjs']); | ||
} else { | ||
const noPhantom = () => { | ||
grunt.log.writeln('no changed modules need phantomjs testing'); | ||
}; | ||
grunt.registerTask('phantomjs-auto', noPhantom); | ||
grunt.registerTask('phantomjs-manual', noPhantom); | ||
grunt.registerTask('list-changed-phantom', noPhantom); | ||
} | ||
|
||
//dupe de dupe dupe | ||
if (browserTests.length > 0) { | ||
grunt.registerTask('list-changed-browser', () => { | ||
const changeList = JSON.stringify(browserTests.reduce((acc, change) => acc.concat(change.name), []), null, 2); | ||
grunt.log.writeln('Changed projects for browser testing:', changeList); | ||
}); | ||
grunt.registerTask('browser-auto', ['list-changed-browser', 'shell:tsc', 'bedrock-auto:browser']); | ||
grunt.registerTask('browser-manual', ['list-changed-browser', 'shell:tsc', 'bedrock-manual:browser']); | ||
} else { | ||
const noBrowser = () => { | ||
grunt.log.writeln('no changed modules need browser testing'); | ||
}; | ||
grunt.registerTask('browser-auto', noBrowser); | ||
grunt.registerTask('browser-manual', noBrowser); | ||
grunt.registerTask('list-changed-browser', noBrowser); | ||
} | ||
|
||
grunt.registerTask('default', []); | ||
|
||
require('load-grunt-tasks')(grunt, { | ||
requireResolution: true, | ||
config: 'package.json', | ||
pattern: ['@ephox/bedrock', 'grunt-shell'] | ||
}); | ||
}; |
Oops, something went wrong.