Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
const deepFreeze = require('deep-freeze-strict');
|
2023-04-25 16:32:51 +02:00
|
|
|
const { loadBuildTypesConfig } = require('../../lib/build-type');
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
const {
|
|
|
|
createRemoveFencedCodeTransform,
|
|
|
|
removeFencedCode,
|
|
|
|
} = require('./remove-fenced-code');
|
2021-09-16 05:18:28 +02:00
|
|
|
const transformUtils = require('./utils');
|
|
|
|
|
|
|
|
jest.mock('./utils', () => ({
|
|
|
|
lintTransformedFile: jest.fn(),
|
|
|
|
}));
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
|
|
|
// The test data is just strings. We get it from a function at the end of this
|
|
|
|
// file because it takes up a lot of lines and is very distracting.
|
|
|
|
const testData = getTestData();
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const MAIN_BUILD = 'build-main';
|
|
|
|
const FLASK_BUILD = 'build-flask';
|
|
|
|
|
|
|
|
const getMinimalFencedCode = (params = FLASK_BUILD) =>
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
`///: BEGIN:ONLY_INCLUDE_IN(${params})
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
`;
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const getFeatures = ({ all, active }) => ({
|
|
|
|
all: new Set(all),
|
|
|
|
active: new Set(active),
|
|
|
|
});
|
|
|
|
|
|
|
|
const buildTypesConfig = loadBuildTypesConfig();
|
|
|
|
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
describe('build/transforms/remove-fenced-code', () => {
|
|
|
|
describe('createRemoveFencedCodeTransform', () => {
|
2021-09-16 05:18:28 +02:00
|
|
|
const { lintTransformedFile: lintTransformedFileMock } = transformUtils;
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
const mockJsFileName = 'file.js';
|
|
|
|
|
2021-09-16 05:18:28 +02:00
|
|
|
beforeEach(() => {
|
|
|
|
lintTransformedFileMock.mockImplementation(() => Promise.resolve());
|
|
|
|
});
|
|
|
|
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
it('returns a PassThrough stream for files with ignored extensions', async () => {
|
|
|
|
const fileContent = '"Valid JSON content"\n';
|
2023-04-25 16:32:51 +02:00
|
|
|
const stream = createRemoveFencedCodeTransform(
|
|
|
|
getFeatures({
|
|
|
|
active: [MAIN_BUILD],
|
|
|
|
all: [MAIN_BUILD],
|
|
|
|
}),
|
|
|
|
)('file.json');
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
let streamOutput = '';
|
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('data', (data) => {
|
|
|
|
streamOutput = streamOutput.concat(data.toString('utf8'));
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.on('end', () => {
|
|
|
|
expect(streamOutput).toStrictEqual(fileContent);
|
2021-09-16 05:18:28 +02:00
|
|
|
expect(lintTransformedFileMock).not.toHaveBeenCalled();
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.write(Buffer.from(fileContent));
|
|
|
|
setTimeout(() => stream.end());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('transforms a file read as a single chunk', async () => {
|
|
|
|
const filePrefix = '// A comment\n';
|
|
|
|
const fileContent = filePrefix.concat(getMinimalFencedCode());
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const stream = createRemoveFencedCodeTransform(
|
|
|
|
getFeatures({
|
|
|
|
active: [MAIN_BUILD],
|
|
|
|
all: [MAIN_BUILD, FLASK_BUILD],
|
|
|
|
}),
|
|
|
|
)(mockJsFileName);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
let streamOutput = '';
|
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('data', (data) => {
|
|
|
|
streamOutput = streamOutput.concat(data.toString('utf8'));
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.on('end', () => {
|
|
|
|
expect(streamOutput).toStrictEqual(filePrefix);
|
2021-09-16 05:18:28 +02:00
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledTimes(1);
|
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledWith(
|
|
|
|
filePrefix,
|
|
|
|
mockJsFileName,
|
|
|
|
);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.end(fileContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('transforms a file read as multiple chunks', async () => {
|
|
|
|
const filePrefix = '// A comment\n';
|
|
|
|
const chunks = filePrefix
|
|
|
|
.concat(getMinimalFencedCode())
|
|
|
|
.split('\n')
|
|
|
|
// The final element in the split array is the empty string, which is
|
|
|
|
// useful for calling .join, but undesirable here.
|
|
|
|
.filter((line) => line !== '')
|
|
|
|
.map((line) => `${line}\n`);
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const stream = createRemoveFencedCodeTransform(
|
|
|
|
getFeatures({
|
|
|
|
active: [MAIN_BUILD],
|
|
|
|
all: [MAIN_BUILD, FLASK_BUILD],
|
|
|
|
}),
|
|
|
|
)(mockJsFileName);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
let streamOutput = '';
|
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('data', (data) => {
|
|
|
|
streamOutput = streamOutput.concat(data.toString('utf8'));
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.on('end', () => {
|
|
|
|
expect(streamOutput).toStrictEqual(filePrefix);
|
2021-09-16 05:18:28 +02:00
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledTimes(1);
|
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledWith(
|
|
|
|
filePrefix,
|
|
|
|
mockJsFileName,
|
|
|
|
);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
chunks.forEach((chunk) => stream.write(chunk));
|
|
|
|
setTimeout(() => stream.end());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles file with fences that is unmodified by the transform', async () => {
|
2023-04-25 16:32:51 +02:00
|
|
|
const fileContent = getMinimalFencedCode(MAIN_BUILD);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const stream = createRemoveFencedCodeTransform(
|
|
|
|
getFeatures({
|
|
|
|
active: [MAIN_BUILD],
|
|
|
|
all: [MAIN_BUILD],
|
|
|
|
}),
|
|
|
|
)(mockJsFileName);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
let streamOutput = '';
|
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('data', (data) => {
|
|
|
|
streamOutput = streamOutput.concat(data.toString('utf8'));
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.on('end', () => {
|
|
|
|
expect(streamOutput).toStrictEqual(fileContent);
|
2021-09-16 05:18:28 +02:00
|
|
|
expect(lintTransformedFileMock).not.toHaveBeenCalled();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.end(fileContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('skips linting for transformed file if shouldLintTransformedFiles is false', async () => {
|
|
|
|
const filePrefix = '// A comment\n';
|
|
|
|
const fileContent = filePrefix.concat(getMinimalFencedCode());
|
|
|
|
|
|
|
|
const stream = createRemoveFencedCodeTransform(
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ all: [MAIN_BUILD, FLASK_BUILD], active: [MAIN_BUILD] }),
|
2021-09-16 05:18:28 +02:00
|
|
|
false,
|
|
|
|
)(mockJsFileName);
|
|
|
|
let streamOutput = '';
|
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('data', (data) => {
|
|
|
|
streamOutput = streamOutput.concat(data.toString('utf8'));
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.on('end', () => {
|
|
|
|
expect(streamOutput).toStrictEqual(filePrefix);
|
|
|
|
expect(lintTransformedFileMock).not.toHaveBeenCalled();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.end(fileContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-11-19 17:35:04 +01:00
|
|
|
it('handles error during code fence removal or parsing', async () => {
|
|
|
|
const fileContent = getMinimalFencedCode().concat(
|
|
|
|
'///: END:ONLY_INCLUDE_IN',
|
|
|
|
);
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const stream = createRemoveFencedCodeTransform(
|
|
|
|
getFeatures({ all: [MAIN_BUILD, FLASK_BUILD], active: [MAIN_BUILD] }),
|
|
|
|
)(mockJsFileName);
|
2021-11-19 17:35:04 +01:00
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('error', (error) => {
|
|
|
|
expect(error.message).toStrictEqual(
|
|
|
|
expect.stringContaining(
|
|
|
|
'A valid fence consists of two fence lines, but the file contains an uneven number, "3", of fence lines.',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledTimes(0);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.end(fileContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-16 05:18:28 +02:00
|
|
|
it('handles transformed file lint failure', async () => {
|
|
|
|
lintTransformedFileMock.mockImplementationOnce(() =>
|
|
|
|
Promise.reject(new Error('lint failure')),
|
|
|
|
);
|
|
|
|
|
|
|
|
const filePrefix = '// A comment\n';
|
|
|
|
const fileContent = filePrefix.concat(getMinimalFencedCode());
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
const stream = createRemoveFencedCodeTransform(
|
|
|
|
getFeatures({ all: [FLASK_BUILD], active: [] }),
|
|
|
|
)(mockJsFileName);
|
2021-09-16 05:18:28 +02:00
|
|
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
stream.on('error', (error) => {
|
|
|
|
expect(error).toStrictEqual(new Error('lint failure'));
|
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledTimes(1);
|
|
|
|
expect(lintTransformedFileMock).toHaveBeenCalledWith(
|
|
|
|
filePrefix,
|
|
|
|
mockJsFileName,
|
|
|
|
);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
|
|
|
stream.end(fileContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('removeFencedCode', () => {
|
|
|
|
const mockFileName = 'file.js';
|
|
|
|
|
|
|
|
// Valid inputs
|
2023-04-25 16:32:51 +02:00
|
|
|
['main', 'flask', 'beta'].forEach((buildType) => {
|
|
|
|
const active = buildTypesConfig.buildTypes[buildType].features;
|
|
|
|
const all = Object.keys(buildTypesConfig.features);
|
|
|
|
const features = getFeatures({ all, active });
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
it(`transforms file with fences for build type "${buildType}"`, () => {
|
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
features,
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
testData.validInputs.withFences,
|
|
|
|
),
|
|
|
|
).toStrictEqual(testData.validOutputs[buildType]);
|
|
|
|
|
2021-10-30 01:45:27 +02:00
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
features,
|
2021-10-30 01:45:27 +02:00
|
|
|
testData.validInputs.extraContentWithFences,
|
|
|
|
),
|
|
|
|
).toStrictEqual(testData.validOutputsWithExtraContent[buildType]);
|
|
|
|
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
// Ensure that the minimal input template is in fact valid
|
2023-04-25 16:32:51 +02:00
|
|
|
const minimalInput = getMinimalFencedCode(`build-${buildType}`);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
expect(
|
2023-04-25 16:32:51 +02:00
|
|
|
removeFencedCode(mockFileName, features, minimalInput),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
).toStrictEqual([minimalInput, false]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`does not modify file without fences for build type "${buildType}"`, () => {
|
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
features,
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
testData.validInputs.withoutFences,
|
|
|
|
),
|
|
|
|
).toStrictEqual([testData.validInputs.withoutFences, false]);
|
2021-10-30 01:45:27 +02:00
|
|
|
|
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
features,
|
2021-10-30 01:45:27 +02:00
|
|
|
testData.validInputs.extraContentWithoutFences,
|
|
|
|
),
|
|
|
|
).toStrictEqual([
|
|
|
|
testData.validInputs.extraContentWithoutFences,
|
|
|
|
false,
|
|
|
|
]);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// This is an edge case for the splicing function
|
|
|
|
it('transforms file with two fence lines', () => {
|
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({
|
|
|
|
active: [FLASK_BUILD],
|
|
|
|
all: [FLASK_BUILD, MAIN_BUILD],
|
|
|
|
}),
|
|
|
|
getMinimalFencedCode(MAIN_BUILD),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
),
|
|
|
|
).toStrictEqual(['', true]);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ignores sentinels preceded by non-whitespace', () => {
|
2023-04-25 16:32:51 +02:00
|
|
|
const validBeginDirective = '///: BEGIN:ONLY_INCLUDE_IN(build-flask)\n';
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
const ignoredLines = [
|
|
|
|
`a ${validBeginDirective}`,
|
|
|
|
`2 ${validBeginDirective}`,
|
|
|
|
`@ ${validBeginDirective}`,
|
|
|
|
];
|
|
|
|
|
|
|
|
ignoredLines.forEach((ignoredLine) => {
|
|
|
|
// These inputs will be transformed
|
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({
|
|
|
|
active: [FLASK_BUILD],
|
|
|
|
all: [FLASK_BUILD, MAIN_BUILD],
|
|
|
|
}),
|
|
|
|
getMinimalFencedCode(MAIN_BUILD).concat(ignoredLine),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
),
|
|
|
|
).toStrictEqual([ignoredLine, true]);
|
|
|
|
|
2022-07-31 20:26:40 +02:00
|
|
|
const modifiedInputWithoutFences =
|
|
|
|
testData.validInputs.withoutFences.concat(ignoredLine);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
|
|
|
// These inputs will not be transformed
|
|
|
|
expect(
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
modifiedInputWithoutFences,
|
|
|
|
),
|
|
|
|
).toStrictEqual([modifiedInputWithoutFences, false]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Invalid inputs
|
|
|
|
it('rejects empty fences', () => {
|
|
|
|
const jsComment = '// A comment\n';
|
|
|
|
|
|
|
|
const emptyFence = getMinimalFencedCode()
|
|
|
|
.split('\n')
|
|
|
|
.filter((line) => line.startsWith('///:'))
|
|
|
|
.map((line) => `${line}\n`)
|
|
|
|
.join('');
|
|
|
|
|
|
|
|
const emptyFenceWithPrefix = jsComment.concat(emptyFence);
|
|
|
|
const emptyFenceWithSuffix = emptyFence.concat(jsComment);
|
|
|
|
const emptyFenceSurrounded = emptyFenceWithPrefix.concat(jsComment);
|
|
|
|
|
|
|
|
const inputs = [
|
|
|
|
emptyFence,
|
|
|
|
emptyFenceWithPrefix,
|
|
|
|
emptyFenceWithSuffix,
|
|
|
|
emptyFenceSurrounded,
|
|
|
|
];
|
|
|
|
|
|
|
|
inputs.forEach((input) => {
|
|
|
|
expect(() =>
|
2023-04-25 16:32:51 +02:00
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
|
|
|
input,
|
|
|
|
),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
).toThrow(
|
|
|
|
`Empty fence found in file "${mockFileName}":\n${emptyFence}`,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects sentinels not followed by a single space and a multi-character alphabetical string', () => {
|
|
|
|
// Matches the sentinel and terminus component of the first line
|
|
|
|
// beginning with "///: TERMINUS"
|
|
|
|
const fenceSentinelAndTerminusRegex = /^\/\/\/: \w+/mu;
|
|
|
|
|
|
|
|
const replacements = [
|
|
|
|
'///:BEGIN',
|
|
|
|
'///:XBEGIN',
|
|
|
|
'///:_BEGIN',
|
|
|
|
'///:B',
|
|
|
|
'///:_',
|
|
|
|
'///: ',
|
|
|
|
'///: B',
|
|
|
|
'///:',
|
|
|
|
];
|
|
|
|
|
|
|
|
replacements.forEach((replacement) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode().replace(
|
|
|
|
fenceSentinelAndTerminusRegex,
|
|
|
|
replacement,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).toThrow(
|
|
|
|
/Fence sentinel must be followed by a single space and an alphabetical string of two or more characters.$/u,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects malformed BEGIN directives', () => {
|
|
|
|
// This is the first line of the minimal input template
|
2023-04-25 16:32:51 +02:00
|
|
|
const directiveString = '///: BEGIN:ONLY_INCLUDE_IN(build-flask)';
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
|
|
|
const replacements = [
|
|
|
|
// Invalid terminus
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BE_GIN:BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
|
|
|
'///: BE6IN:BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
|
|
|
'///: BEGIN7:BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
|
|
|
'///: BeGIN:ONLY_INCLUDE_IN(build-flask)',
|
|
|
|
'///: BE3:BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
|
|
|
'///: BEG-IN:BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
|
|
|
'///: BEG N:BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
|
|
|
// Invalid commands
|
|
|
|
'///: BEGIN:ONLY-INCLUDE_IN(flask)',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE:IN(flask)',
|
|
|
|
'///: BEGIN:ONL6_INCLUDE_IN(flask)',
|
|
|
|
'///: BEGIN:ONLY_IN@LUDE_IN(flask)',
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BEGIN:ONLy_INCLUDE_IN(build-flask)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'///: BEGIN:ONLY INCLUDE_IN(flask)',
|
|
|
|
|
|
|
|
// Invalid parameters
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(,flask)',
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask,)',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask,,main)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(,)',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN()',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN( )',
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask]',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN[flask)',
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask.main)',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask,@)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(fla k)',
|
|
|
|
|
|
|
|
// Stuff after the directive
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask) A',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask) 9',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask)A',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask)9',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask)_',
|
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask))',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
replacements.forEach((replacement) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode().replace(directiveString, replacement),
|
|
|
|
),
|
|
|
|
).toThrow(
|
|
|
|
new RegExp(
|
|
|
|
`${replacement.replace(
|
|
|
|
/([()[\]])/gu,
|
|
|
|
'\\$1',
|
|
|
|
)}":\nFailed to parse fence directive.$`,
|
|
|
|
'u',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects malformed END directives', () => {
|
|
|
|
// This is the last line of the minimal input template
|
|
|
|
const directiveString = '///: END:ONLY_INCLUDE_IN';
|
|
|
|
|
|
|
|
const replacements = [
|
|
|
|
// Invalid terminus
|
|
|
|
'///: ENx:ONLY_INCLUDE_IN',
|
|
|
|
'///: EN3:ONLY_INCLUDE_IN',
|
|
|
|
'///: EN_:ONLY_INCLUDE_IN',
|
|
|
|
'///: EN :ONLY_INCLUDE_IN',
|
|
|
|
'///: EN::ONLY_INCLUDE_IN',
|
|
|
|
|
|
|
|
// Invalid commands
|
|
|
|
'///: END:ONLY-INCLUDE_IN',
|
|
|
|
'///: END::ONLY_INCLUDE_IN',
|
|
|
|
'///: END:ONLY_INCLUDE:IN',
|
|
|
|
'///: END:ONL6_INCLUDE_IN',
|
|
|
|
'///: END:ONLY_IN@LUDE_IN',
|
|
|
|
'///: END:ONLy_INCLUDE_IN',
|
|
|
|
'///: END:ONLY INCLUDE_IN',
|
|
|
|
|
|
|
|
// Stuff after the directive
|
|
|
|
'///: END:ONLY_INCLUDE_IN A',
|
|
|
|
'///: END:ONLY_INCLUDE_IN 9',
|
|
|
|
'///: END:ONLY_INCLUDE_IN _',
|
|
|
|
];
|
|
|
|
|
|
|
|
replacements.forEach((replacement) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode().replace(directiveString, replacement),
|
|
|
|
),
|
|
|
|
).toThrow(
|
|
|
|
new RegExp(
|
|
|
|
`${replacement}":\nFailed to parse fence directive.$`,
|
|
|
|
'u',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects files with uneven number of fence lines', () => {
|
|
|
|
const additions = [
|
2023-04-25 16:32:51 +02:00
|
|
|
'///: BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'///: END:ONLY_INCLUDE_IN',
|
|
|
|
];
|
|
|
|
additions.forEach((addition) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode().concat(addition),
|
|
|
|
),
|
|
|
|
).toThrow(
|
|
|
|
/A valid fence consists of two fence lines, but the file contains an uneven number, "3", of fence lines.$/u,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects invalid terminuses', () => {
|
|
|
|
const testCases = [
|
|
|
|
['BEGIN', ['KAPLAR', 'FLASK', 'FOO']],
|
|
|
|
['END', ['KAPLAR', 'FOO', 'BAR']],
|
|
|
|
];
|
|
|
|
|
|
|
|
testCases.forEach(([validTerminus, replacements]) => {
|
|
|
|
replacements.forEach((replacement) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode().replace(validTerminus, replacement),
|
|
|
|
),
|
|
|
|
).toThrow(
|
|
|
|
new RegExp(
|
|
|
|
`Line contains invalid directive terminus "${replacement}".$`,
|
|
|
|
'u',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects invalid commands', () => {
|
|
|
|
const testCases = [
|
|
|
|
[/ONLY_INCLUDE_IN\(/mu, ['ONLY_KEEP_IN(', 'FLASK(', 'FOO(']],
|
|
|
|
[/ONLY_INCLUDE_IN$/mu, ['ONLY_KEEP_IN', 'FLASK', 'FOO']],
|
|
|
|
];
|
|
|
|
|
|
|
|
testCases.forEach(([validCommand, replacements]) => {
|
|
|
|
replacements.forEach((replacement) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode().replace(validCommand, replacement),
|
|
|
|
),
|
|
|
|
).toThrow(
|
|
|
|
new RegExp(
|
|
|
|
`Line contains invalid directive command "${replacement.replace(
|
|
|
|
'(',
|
|
|
|
'',
|
|
|
|
)}".$`,
|
|
|
|
'u',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects invalid command parameters', () => {
|
|
|
|
const testCases = [
|
2023-04-25 16:32:51 +02:00
|
|
|
[
|
|
|
|
'bar',
|
|
|
|
['bar', 'build-flask,bar', 'build-flask,build-beta,build-main,bar'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Foo',
|
|
|
|
['Foo', 'build-flask,Foo', 'build-flask,build-beta,build-main,Foo'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'b3ta',
|
|
|
|
[
|
|
|
|
'b3ta',
|
|
|
|
'build-flask,b3ta',
|
|
|
|
'build-flask,build-beta,build-main,b3ta',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'bEta',
|
|
|
|
[
|
|
|
|
'bEta',
|
|
|
|
'build-flask,bEta',
|
|
|
|
'build-flask,build-beta,build-main,bEta',
|
|
|
|
],
|
|
|
|
],
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
testCases.forEach(([invalidParam, replacements]) => {
|
|
|
|
replacements.forEach((replacement) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({
|
|
|
|
active: [FLASK_BUILD],
|
|
|
|
all: [FLASK_BUILD, MAIN_BUILD, 'build-beta'],
|
|
|
|
}),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode(replacement),
|
|
|
|
),
|
|
|
|
).toThrow(
|
2023-04-25 16:32:51 +02:00
|
|
|
new RegExp(
|
|
|
|
`"${invalidParam}" is not a declared build feature.$`,
|
|
|
|
'u',
|
|
|
|
),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Should fail for empty params
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
getMinimalFencedCode('').replace('()', ''),
|
|
|
|
),
|
|
|
|
).toThrow(/No params specified.$/u);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('rejects directive pairs with wrong terminus order', () => {
|
|
|
|
// We need more than one directive pair for this test
|
2023-04-25 16:32:51 +02:00
|
|
|
const input = getMinimalFencedCode().concat(
|
|
|
|
getMinimalFencedCode('build-beta'),
|
|
|
|
);
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
|
|
|
const expectedBeginError =
|
|
|
|
'The first directive of a pair must be a "BEGIN" directive.';
|
|
|
|
const expectedEndError =
|
|
|
|
'The second directive of a pair must be an "END" directive.';
|
|
|
|
const testCases = [
|
|
|
|
[
|
2023-04-25 16:32:51 +02:00
|
|
|
'BEGIN:ONLY_INCLUDE_IN(build-flask)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'END:ONLY_INCLUDE_IN',
|
|
|
|
expectedBeginError,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
/END:ONLY_INCLUDE_IN/mu,
|
2023-04-25 16:32:51 +02:00
|
|
|
'BEGIN:ONLY_INCLUDE_IN(build-main)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
expectedEndError,
|
|
|
|
],
|
|
|
|
[
|
2023-04-25 16:32:51 +02:00
|
|
|
'BEGIN:ONLY_INCLUDE_IN(build-beta)',
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
'END:ONLY_INCLUDE_IN',
|
|
|
|
expectedBeginError,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
testCases.forEach(([target, replacement, expectedError]) => {
|
|
|
|
expect(() =>
|
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
2023-04-25 16:32:51 +02:00
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
input.replace(target, replacement),
|
|
|
|
),
|
|
|
|
).toThrow(expectedError);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-12 18:37:29 +01:00
|
|
|
it('ignores files with inline source maps', () => {
|
|
|
|
// This is so that there isn't an unnecessary second execution of
|
|
|
|
// removeFencedCode with a transpiled version of the same file
|
|
|
|
const input = getTestData().validInputs.extraContentWithFences.concat(
|
|
|
|
'\n//# sourceMappingURL=as32e32wcwc2234f2ew32cnin4243f4nv9nsdoivnxzoivnd',
|
|
|
|
);
|
|
|
|
expect(
|
2023-04-25 16:32:51 +02:00
|
|
|
removeFencedCode(
|
|
|
|
mockFileName,
|
|
|
|
getFeatures({ active: [FLASK_BUILD], all: [FLASK_BUILD] }),
|
|
|
|
input,
|
|
|
|
),
|
2022-01-12 18:37:29 +01:00
|
|
|
).toStrictEqual([input, false]);
|
|
|
|
});
|
|
|
|
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
// We can't do this until there's more than one command
|
|
|
|
it.todo('rejects directive pairs with mismatched commands');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function getTestData() {
|
|
|
|
const data = {
|
|
|
|
validInputs: {
|
|
|
|
withFences: `
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
Conditionally_Included
|
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-02-08 10:24:01 +01:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
|
|
|
Conditionally_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
`,
|
|
|
|
|
2021-10-30 01:45:27 +02:00
|
|
|
extraContentWithFences: `
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2021-10-30 01:45:27 +02:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-10-30 01:45:27 +02:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
Conditionally_Included
|
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-02-08 10:24:01 +01:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Conditionally_Included
|
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
Always_Included
|
|
|
|
`,
|
|
|
|
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
withoutFences: `
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
`,
|
|
|
|
|
|
|
|
extraContentWithoutFences: `
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
Always_Included
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
`,
|
|
|
|
},
|
|
|
|
|
|
|
|
validOutputs: {
|
|
|
|
beta: [
|
|
|
|
`
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
`,
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
flask: [
|
|
|
|
`
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-02-08 10:24:01 +01:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
|
|
|
|
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Conditionally_Included
|
|
|
|
|
2023-04-25 16:32:51 +02:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
`,
|
2023-04-25 16:32:51 +02:00
|
|
|
false,
|
2023-03-01 10:38:15 +01:00
|
|
|
],
|
|
|
|
mmi: [
|
|
|
|
`
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
`,
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
validOutputsWithExtraContent: {
|
|
|
|
beta: [
|
|
|
|
`
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2021-10-30 01:45:27 +02:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-03-01 10:38:15 +01:00
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
`,
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
flask: [
|
|
|
|
`
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-02-08 10:24:01 +01:00
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask,build-beta,desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
2023-02-08 10:24:01 +01:00
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2023-02-08 10:24:01 +01:00
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2023-04-25 16:32:51 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-flask)
|
|
|
|
Conditionally_Included
|
|
|
|
Conditionally_Included
|
|
|
|
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(desktop)
|
2023-03-01 10:38:15 +01:00
|
|
|
Conditionally_Included
|
2023-02-08 10:24:01 +01:00
|
|
|
Conditionally_Included
|
|
|
|
|
2023-03-01 10:38:15 +01:00
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
`,
|
2023-04-25 16:32:51 +02:00
|
|
|
false,
|
2023-03-01 10:38:15 +01:00
|
|
|
],
|
|
|
|
mmi: [
|
|
|
|
`
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
|
|
|
Always_Included
|
2021-10-30 01:45:27 +02:00
|
|
|
Always_Included
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
`,
|
|
|
|
true,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-02-08 10:24:01 +01:00
|
|
|
data.validOutputs.desktop = [data.validInputs.withFences, false];
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
data.validOutputs.main = [data.validInputs.withoutFences, true];
|
2021-10-30 01:45:27 +02:00
|
|
|
|
2023-02-08 10:24:01 +01:00
|
|
|
data.validOutputsWithExtraContent.desktop = [
|
2021-10-30 01:45:27 +02:00
|
|
|
data.validInputs.extraContentWithFences,
|
|
|
|
false,
|
|
|
|
];
|
|
|
|
data.validOutputsWithExtraContent.main = [
|
|
|
|
data.validInputs.extraContentWithoutFences,
|
|
|
|
true,
|
|
|
|
];
|
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.
Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.
By way of example, this build system feature allows us to add fences like this:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
///: BEGIN:ONLY_INCLUDE_IN(beta)
PluginController: this.pluginController,
///: END:ONLY_INCLUDE_IN
});
```
Which at build time are transformed to the following if the build type is not `beta`:
```javascript
this.store.updateStructure({
...,
GasFeeController: this.gasFeeController,
TokenListController: this.tokenListController,
});
```
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 19:00:04 +02:00
|
|
|
return deepFreeze(data);
|
|
|
|
}
|