-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from davidjoy/main
Build Milestone: frontend-build migrated into the library
- Loading branch information
Showing
68 changed files
with
14,890 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
coverage/* | ||
dist/ | ||
node_modules/ | ||
__mocks__/ | ||
__snapshots__/ |
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,18 @@ | ||
const path = require('path'); | ||
|
||
const { createConfig } = require('.'); | ||
|
||
module.exports = createConfig('eslint', { | ||
ignorePatterns: [ | ||
'cli/test-app', | ||
], | ||
parserOptions: { | ||
project: path.resolve(__dirname, './tsconfig.json'), | ||
}, | ||
rules: { | ||
'no-console': 'off', | ||
'import/no-dynamic-require': 'off', | ||
'global-require': 'off', | ||
'no-template-curly-in-string': 'off', | ||
}, | ||
}); |
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,31 @@ | ||
name: Default CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '**' | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Nodejs Env | ||
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV | ||
- name: Setup Nodejs | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ env.NODE_VER }} | ||
- name: Install dependencies | ||
run: | | ||
npm ci | ||
cd cli/test-app | ||
npm ci | ||
- name: Lint | ||
run: npm run lint | ||
- name: Test | ||
run: npm run test |
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 @@ | ||
# check package-lock file version | ||
|
||
name: Lockfile Version check | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
version-check: | ||
uses: openedx/.github/.github/workflows/lockfile-check.yml@master |
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,8 @@ | ||
.DS_Store | ||
.eslintcache | ||
.idea | ||
.vscode | ||
coverage | ||
dist | ||
node_modules | ||
npm-debug.log |
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 @@ | ||
18 |
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,83 @@ | ||
#!/usr/bin/env node | ||
|
||
const chalk = require('chalk'); | ||
|
||
const presets = require('../lib/presets'); | ||
|
||
/** | ||
* TLDR: | ||
* - Find the command to be run in process.argv | ||
* - Remove 'openedx' in process.argv | ||
* - Add a --config option to process.argv if one is missing | ||
* - Execute the command's bin script by pulling it directly in with require() | ||
* | ||
* This file forwards cli commands by manipulating process.argv values and then | ||
* directly requiring bin scripts from the specified packages (as opposed to | ||
* attempting to run them from the aliases npm copies to the .bin folder upon | ||
* install). This seems like a relatively safe thing to do since these file | ||
* names are identical to their cli name and this method of requiring/executing | ||
* them should behave the same as if run from the command line as usual. | ||
*/ | ||
|
||
function optionExists(keys) { | ||
return process.argv.some((arg) => { | ||
// eslint-disable-next-line no-plusplus | ||
for (let i = 0; i < keys.length; i++) { | ||
if (arg.startsWith(keys[i])) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
// Ensures that a config option already exists and if it does not adds a default | ||
function ensureConfigOption(preset, keys = ['--config', '-c']) { | ||
if (!optionExists(keys)) { | ||
console.log(`Running with resolved config:\n${preset.resolvedFilepath}\n`); | ||
process.argv.push(keys[0]); | ||
process.argv.push(preset.resolvedFilepath); | ||
} | ||
} | ||
|
||
// commandName is the third argument after node and 'openedx' | ||
const commandName = process.argv[2]; | ||
|
||
// remove 'openedx' from process.argv to allow subcommands to read options properly | ||
process.argv.splice(1, 1); | ||
|
||
switch (commandName) { | ||
case 'eslint': | ||
ensureConfigOption(presets.eslint); | ||
// eslint-disable-next-line import/extensions, import/no-extraneous-dependencies | ||
require('.bin/eslint'); | ||
break; | ||
case 'jest': | ||
ensureConfigOption(presets.jest); | ||
require('jest/bin/jest'); | ||
break; | ||
case 'webpack': | ||
ensureConfigOption(presets.webpack); | ||
require('webpack/bin/webpack'); | ||
break; | ||
case 'webpack-dev-server': | ||
ensureConfigOption(presets.webpackDevServer); | ||
require('webpack-dev-server/bin/webpack-dev-server'); | ||
break; | ||
case 'formatjs': { | ||
const commonArgs = [ | ||
'--format', 'node_modules/@openedx/frontend-base/lib/formatter.js', | ||
'--ignore', 'src/**/*.json', | ||
'--out-file', './temp/formatjs/Default.messages.json', | ||
'--', 'src/**/*.js*', | ||
]; | ||
process.argv = process.argv.concat(commonArgs); | ||
require('@formatjs/cli/bin/formatjs'); | ||
break; | ||
} | ||
case 'serve': | ||
require('../lib/scripts/serve'); | ||
break; | ||
default: | ||
console.log(chalk.red(`[ERROR] openedx: The command ${chalk.bold.red(commandName)} is unsupported.`)); | ||
} |
Empty file.
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,3 @@ | ||
PORT=3000 | ||
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico | ||
TEST_VARIABLE='foo' |
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,2 @@ | ||
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico | ||
TEST_VARIABLE='foo' |
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,5 @@ | ||
coverage/* | ||
dist/ | ||
node_modules/ | ||
__mocks__/ | ||
__snapshots__/ |
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 @@ | ||
const { createConfig } = require('@openedx/frontend-base'); | ||
|
||
module.exports = createConfig('eslint', { | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
}, | ||
}); |
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,6 @@ | ||
module.exports = { | ||
FALSE_VALUE: false, | ||
CORRECT_BOOL_VALUE: 'Good, false meant false. We did not cast a boolean to a string.', | ||
INCORRECT_BOOL_VALUE: 'Why was a false boolean true?', | ||
INTEGER_VALUE: 123, | ||
}; |
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,8 @@ | ||
const { createConfig } = require('@openedx/frontend-base'); | ||
|
||
module.exports = createConfig('jest', { | ||
moduleNameMapper: { | ||
'\\.svg$': '<rootDir>/src/__mocks__/svg.js', | ||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/src/__mocks__/file.js', | ||
}, | ||
}); |
Oops, something went wrong.