Skip to content

Commit

Permalink
feat(npm-scripts)!: remove metal and soy support
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceosterhaus committed Oct 18, 2023
1 parent d35e6af commit 70a6f90
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 745 deletions.
4 changes: 1 addition & 3 deletions projects/npm-tools/packages/npm-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ npm install --save-dev @liferay/npm-scripts

### build

Build script that compiles all necessary JavaScript, soy, and bundles it together using `liferay-npm-bundler`.
Build script that compiles all necessary JavaScript and bundles it together using `liferay-npm-bundler`.

```sh
liferay-npm-scripts build
```

Do you have soy dependencies? `build` should automatically detect them.

Do you need to use `liferay-npm-bridge-generator`? Just add a `.npmbridgerc` file and follow the configuration options [here](https://github.com/liferay/liferay-npm-build-tools/wiki/How-to-use-liferay-npm-bridge-generator).

### check
Expand Down
1 change: 0 additions & 1 deletion projects/npm-tools/packages/npm-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"liferay-npm-bundler-plugin-replace-browser-modules": "2.29.0",
"liferay-npm-bundler-plugin-resolve-linked-dependencies": "2.29.0",
"liferay-theme-tasks": "11.5.1",
"metal-tools-soy": "4.3.2",
"mini-css-extract-plugin": "0.11.2",
"minimist": "^1.2.0",
"path-browserify": "^1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ module.exports = {
transform: {
/* eslint-disable sort-keys */
'\\.scss$': path.join(__dirname, '..', 'jest', 'transformSass.js'),
'\\.soy$': path.join(__dirname, '..', 'jest', 'transformSoy.js'),
'.+': path.join(__dirname, '..', 'jest', 'transformBabel.js'),
/* eslint-enable sort-keys */
},
transformIgnorePatterns: ['/node_modules/', '<rootDir>/.*\\.soy$'],
transformIgnorePatterns: ['/node_modules/'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -77,92 +77,15 @@ module.exports = {
'sources': ['src/main/resources/META-INF/resources'],
},

// Passed to:
// - `metalsoy` executable (via `generateSoyDependencies()`).

dependencies: [
'clay-alert',
'clay-autocomplete',
'clay-badge',
'clay-button',
'clay-card',
'clay-card-grid',
'clay-checkbox',
'clay-collapse',
'clay-component',
'clay-data-provider',
'clay-dataset-display',
'clay-dropdown',
'clay-icon',
'clay-label',
'clay-link',
'clay-list',
'clay-loading-indicator',
'clay-management-toolbar',
'clay-modal',
'clay-multi-select',
'clay-navigation-bar',
'clay-pagination',
'clay-pagination-bar',
'clay-portal',
'clay-progress-bar',
'clay-radio',
'clay-select',
'clay-sticker',
'clay-table',
'clay-tooltip',
'frontend-js-metal-web',
'frontend-js-react-web',
'frontend-js-web',
'frontend-taglib-clay',
'frontend-taglib',
'hello-soy-web',
'metal',
'metal-affix',
'metal-ajax',
'metal-anim',
'metal-aop',
'metal-assertions',
'metal-clipboard',
'metal-component',
'metal-debounce',
'metal-dom',
'metal-drag-drop',
'metal-events',
'metal-incremental-dom',
'metal-jsx',
'metal-key',
'metal-keyboard-focus',
'metal-multimap',
'metal-pagination',
'metal-path-parser',
'metal-position',
'metal-promise',
'metal-router',
'metal-scrollspy',
'metal-soy',
'metal-soy-bundle',
'metal-state',
'metal-storage',
'metal-structs',
'metal-throttle',
'metal-toggler',
'metal-uri',
'metal-useragent',
'metal-web-component',
],

// Passed to:
// - `babel` executable (via `runBabel()`).
// - `jest` executable (via resolver.js).
// - `metalsoy` executable (via `buildSoy()`).

input: 'src/main/resources/META-INF/resources',

// Passed to:
// - `babel` executable (via `runBabel()`).
// - `jest` executable (via resolver.js).
// - `translateSoy()`.
// - `minify()`.

output: 'build/node/packageRunBuild/resources',
Expand All @@ -176,7 +99,7 @@ module.exports = {
],

// Used in various places to keep intermediate artefacts out of Gradle's
// way (see `buildSoy()`, `withTempFile()`, etc).
// way (see `withTempFile()`, etc).

temp: 'build/npmscripts',
},
Expand Down
26 changes: 1 addition & 25 deletions projects/npm-tools/packages/npm-scripts/src/jest/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/

const path = require('path');

const getMergedConfig = require('../utils/getMergedConfig');

const BUILD_CONFIG = getMergedConfig('npmscripts', 'build');
const CWD = process.cwd();

const INPUT = BUILD_CONFIG.input.replace('/', path.sep);
const OUTPUT = BUILD_CONFIG.output;

module.exports = function (request, options) {
const {basedir, defaultResolver} = options;

// Redirect imports to .soy.js files from input to output directory

if (basedir.startsWith(CWD)) {
if (/\.soy(?:\.js)?$/.test(request)) {
const dir = basedir.replace(INPUT, OUTPUT);

return path.join(
dir,
path.dirname(request),
path.basename(request, '.js') + '.js'
);
}
}
const {defaultResolver} = options;

// Redirect .css files to our empty.css mock file

Expand Down
31 changes: 0 additions & 31 deletions projects/npm-tools/packages/npm-scripts/src/jest/transformSoy.js

This file was deleted.

24 changes: 1 addition & 23 deletions projects/npm-tools/packages/npm-scripts/src/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ let runBridge = require('../utils/runBridge');
let runBundler = require('../utils/runBundler');
let runWebpackAsBundler = require('../utils/runWebpackAsBundler');
const setEnv = require('../utils/setEnv');
let {buildSoy, cleanSoy, soyExists, translateSoy} = require('../utils/soy');
const validateConfig = require('../utils/validateConfig');
let webpack = require('./webpack');

Expand All @@ -42,9 +41,7 @@ const CWD = process.cwd();

({
buildSass,
buildSoy,
cleanCache,
cleanSoy,
expandGlobs,
hasRootConfigChanged,
isCacheValid,
Expand All @@ -55,14 +52,10 @@ const CWD = process.cwd();
runTSC,
runWebpackAsBundler,
setCache,
soyExists,
translateSoy,
webpack,
} = instrument({
buildSass,
buildSoy,
cleanCache,
cleanSoy,
expandGlobs,
hasRootConfigChanged,
isCacheValid,
Expand All @@ -73,8 +66,6 @@ const CWD = process.cwd();
runTSC,
runWebpackAsBundler,
setCache,
soyExists,
translateSoy,
webpack,
}));

Expand Down Expand Up @@ -108,7 +99,7 @@ const ROOT_CONFIGS = [
* Babel and liferay-npm-bundler are run unless the disable flag is set,
* liferay-npm-bridge-generator and webpack are run if the corresponding
* ".npmbridgerc" and "webpack.config.js" files, respectively, are
* present, and soy is run when soy files are detected.
* present.
* `minify()` is run unless `NODE_ENV` is `development`.
*/
module.exports = async function (...args) {
Expand Down Expand Up @@ -143,7 +134,6 @@ module.exports = async function (...args) {
path.join(BUILD_CONFIG.input, '**/*.json'),
path.join(BUILD_CONFIG.input, '**/*.jsx'),
path.join(BUILD_CONFIG.input, '**/*.scss'),
path.join(BUILD_CONFIG.input, '**/*.soy'),
path.join(BUILD_CONFIG.input, '**/*.ts'),
path.join(BUILD_CONFIG.input, '**/*.tsx'),
...ROOT_CONFIGS,
Expand Down Expand Up @@ -181,12 +171,6 @@ module.exports = async function (...args) {
log(`BUILD JS: No previous build detected.`);
}

const useSoy = soyExists();

if (useSoy) {
buildSoy();
}

if (inputPathExists) {
const isTypeScript = fs.existsSync('tsconfig.json');

Expand Down Expand Up @@ -303,16 +287,10 @@ module.exports = async function (...args) {
);
}

translateSoy(BUILD_CONFIG.output);

if (fs.existsSync(path.join(CWD, '.npmbridgerc'))) {
runBridge();
}

if (useSoy) {
cleanSoy();
}

if (process.env.NODE_ENV !== 'development') {
await minify();
}
Expand Down
11 changes: 0 additions & 11 deletions projects/npm-tools/packages/npm-scripts/src/scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const fs = require('fs');
const SignalHandler = require('../utils/SignalHandler');
const getMergedConfig = require('../utils/getMergedConfig');
const log = require('../utils/log');
const {buildSoy, cleanSoy, soyExists} = require('../utils/soy');
const spawnSync = require('../utils/spawnSync');

const BABEL_CONFIG = getMergedConfig('babel');
Expand All @@ -21,8 +20,6 @@ const PREFIX_BACKUP = 'TEMP-';
* Main script that runs `jest` with a merged config
*/
module.exports = function (arrArgs = []) {
const useSoy = soyExists();

const CONFIG_PATH = 'TEMP_jest.config.json';

fs.writeFileSync(CONFIG_PATH, JSON.stringify(JEST_CONFIG));
Expand All @@ -34,10 +31,6 @@ module.exports = function (arrArgs = []) {
});

try {
if (useSoy) {
buildSoy();
}

const env = {
...process.env,
NODE_ENV: 'test',
Expand All @@ -59,10 +52,6 @@ module.exports = function (arrArgs = []) {
spawnSync('jest', ['--config', CONFIG_PATH, ...arrArgs.slice(1)], {
env,
});

if (useSoy) {
cleanSoy();
}
}
finally {
dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function setCache(moduleName, srcFiles, output) {
output + '/**/*.jsx',
output + '/**/*.map',
output + '/**/*.scss',
output + '/**/*.soy',
output + '/**/*.ts',
output + '/**/*.tsx',
],
Expand Down

This file was deleted.

Loading

0 comments on commit 70a6f90

Please sign in to comment.