Skip to content

Commit

Permalink
Release 12.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
benm071 committed Apr 14, 2022
1 parent fc13710 commit 8dc7e93
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# @oracle/oraclejet-tooling 12.0.0
# @oracle/oraclejet-tooling 12.1.0

## About the tooling API
This tooling API contains methods to build and serve Oracle JET web and hybrid mobile apps. It is intended to be used with task running tools such as grunt or gulp. The APIs can also be invoked directly.

This is an open source project maintained by Oracle Corp.

## Installation
This module will be automatically installed when you scaffold a web or hybrid mobile app following the [Oracle JET Developers Guide](http://www.oracle.com/pls/topic/lookup?ctx=jet1200&id=homepage).
This module will be automatically installed when you scaffold a web or hybrid mobile app following the [Oracle JET Developers Guide](http://www.oracle.com/pls/topic/lookup?ctx=jet1210&id=homepage).

## [Contributing](https://github.com/oracle/oraclejet-tooling/blob/master/CONTRIBUTING.md)
Oracle JET is an open source project. Pull Requests are currently not being accepted. See
Expand Down
2 changes: 1 addition & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Release Notes for oraclejet-tooling ##

### 12.0.0
### 12.1.0

### 11.0.0
* oraclejet-tooling now requires node 12.21 or later
Expand Down
3 changes: 3 additions & 0 deletions lib/buildCommon/stripLocalComponentJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ function deleteAttributesRecursively(requiredAttributes, nonRequiredExtensionAtt
if (typeof attributeObject !== 'object' || attributeObject === null) {
return;
}
if (parentAttribute === 'value') {
return;
}
deleteAttributes(requiredAttributes, nonRequiredExtensionAttributes,
attributeObject, parentAttribute);
const attributes = Object.getOwnPropertyNames(attributeObject);
Expand Down
2 changes: 1 addition & 1 deletion lib/defaultconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module.exports = {
cwd: paths.src.common,
src: [
'**',
`!${paths.src.javascript}/**/*.js`,
(paths.src.javascript === paths.src.typescript) ? `${paths.src.javascript}/**/*.js` : `!${paths.src.javascript}/**/*.js`,
`${paths.src.javascript}/main.js`,
`${paths.src.javascript}/libs/**`,
`!${paths.src.javascript}/libs/**/*debug*`,
Expand Down
2 changes: 1 addition & 1 deletion lib/rjsConfigGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function _getExchangeCcaPathMapping(context, buildType, masterJson, requirejs) {
exchangeComponentPath = path.join(exchangeComponentPath, version);
}
if (buildType === 'release' && _isMinified(exchangeComponent, version)) {
exchangeComponentPath = path.join(exchangeComponentPath, 'min');
exchangeComponentPath = 'empty:';
}
}
pathMappingObj[exchangeComponent] = requirejs ? exchangeComponentPath : `'${exchangeComponentPath}'`;
Expand Down
26 changes: 15 additions & 11 deletions lib/scopes/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ component.add = function (componentNames, options) {
.then(() => { // eslint-disable-line
return exchangeUtils.resolve('add', componentNames, options);
})
.then(_executeSolutions)
.then(result => _executeSolutions(result, options))
.then(() => {
util.log.success(`Component(s) '${componentNames}' added.`, options);
resolve();
Expand All @@ -70,7 +70,7 @@ component.add = function (componentNames, options) {
});
};

function _executeSolutions(resolutionServiceResponse) {
function _executeSolutions(resolutionServiceResponse, options) {
return new Promise((resolve, reject) => {
if (resolutionServiceResponse.solutions.length === 0) {
if (resolutionServiceResponse.message) {
Expand All @@ -82,10 +82,10 @@ function _executeSolutions(resolutionServiceResponse) {
util.log('Updating project components.');
_applyEnvironmentChangesRemove(resolutionServiceResponse.solutions[0])
.then((solution) => { // eslint-disable-line
return _applyEnvironmentChangesAddOrUpdate(solution, 'add');
return _applyEnvironmentChangesAddOrUpdate(solution, 'add', options);
})
.then((solution) => { // eslint-disable-line
return _applyEnvironmentChangesAddOrUpdate(solution, 'update');
return _applyEnvironmentChangesAddOrUpdate(solution, 'update', options);
})
.then(_applyConfigChanges)
.then(() => {
Expand Down Expand Up @@ -158,7 +158,7 @@ function _applyEnvironmentChangesRemove(solution) {
});
}

function _applyEnvironmentChangesAddOrUpdate(solution, type) {
function _applyEnvironmentChangesAddOrUpdate(solution, type, options) {
return new Promise((resolve, reject) => {
const changes = solution.environmentChanges;
const componentsDirPath = util.getConfiguredPaths().exchangeComponents;
Expand Down Expand Up @@ -215,7 +215,7 @@ function _applyEnvironmentChangesAddOrUpdate(solution, type) {
});
}
});
_installComponents(componentDescriptors)
_installComponents(componentDescriptors, options)
.then(() => {
if (componentDescriptors.length > 0) {
util.log(`${counter} component(s) added to project.`);
Expand Down Expand Up @@ -314,9 +314,10 @@ function _mergeChanges(components, changes) {
*
* @public
* @param {Array} componentDescriptors
* @param {Object} options
* @returns {Promise}
*/
function _installComponents(componentDescriptors) {
function _installComponents(componentDescriptors, options) {
const profiler = util.profilerFactory(measurementsMap);

return new Promise((resolve, reject) => {
Expand All @@ -329,7 +330,7 @@ function _installComponents(componentDescriptors) {
profiler.profile(_fetchArchive, componentMetadata, 'fetchComponent')
.then(compMetadata2 => profiler.profile(_unpackArchive, compMetadata2, 'unpackArchive'))
.then(_enhanceComponentMetadata)
.then(compMetadata3 => profiler.profile(_installReferenceComponent, compMetadata3, 'installReferences'))
.then(compMetadata3 => profiler.profile(_installReferenceComponent, { metadata: compMetadata3, options }, 'installReferences'))
.then(_shufflePackComponentResources)
.then(_addToTsconfigPathMapping)
.then(() => {
Expand Down Expand Up @@ -492,18 +493,21 @@ function _enhanceComponentMetadata(componentMetadata) {
* ## _installReferenceComponent
*
* @private
* @param {Object} componentMetadata
* @param {Object} obj: componentMetadata, options
* @returns {Promise}
*/
function _installReferenceComponent(componentMetadata) {
function _installReferenceComponent(obj) {
return new Promise((resolve, reject) => {
const componentMetadata = obj.metadata;
const options = obj.options;
if (componentMetadata.type === 'reference') {
// Call npm install <componentName>
const npmPackageName = componentMetadata.component.package;
const npmPackageVersion = componentMetadata.component.version;
const npmPackage = `${npmPackageName}@${npmPackageVersion}`;
const installer = util.getInstallerCommand({ options });
util.log(`Installing npm package '${npmPackage}' referenced by '${componentMetadata.fullName}.'`);
util.spawn('npm', ['install', npmPackage])
util.spawn(installer.installer, [installer.verbs.install, npmPackage])
.then(() => {
util.log(`Npm package '${npmPackage}' was successfully installed.`);
resolve(componentMetadata);
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/pack/component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pack@",
"version": "1.0.0",
"jetVersion": "12.0.0",
"jetVersion": "12.1.0",
"type": "pack",
"displayName": "A user friendly, translatable name of the pack.",
"description": "A translatable high-level description for the pack.",
Expand Down
7 changes: 7 additions & 0 deletions lib/webpack/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = (options) => {
const ojetUtils = require('../util');
// eslint-disable-next-line global-require
const setup = require('./setup');
// eslint-disable-next-line global-require
const webpackUtils = require('./utils');
return new Promise((resolve, reject) => {
ojetUtils.log('Building with Webpack');
const { context, webpack, webpackConfig } = setup({ options, platform: 'web' });
Expand All @@ -21,6 +23,11 @@ module.exports = (options) => {
}
reject(err.details);
}
// In release mode, we inject the redwood files link directly into the index.html
// in the src folder. This process removes the <!-- css: redwood --> tag, which we
// need to restore and remove injected link that at this point will already be
// reflected in web/index.html.
webpackUtils.restoreRedwoodTag(options);
console.log(stats.toString());
resolve(context);
});
Expand Down
7 changes: 7 additions & 0 deletions lib/webpack/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
const path = require('path');

const ojetUtils = require('../util');
const webpackUtils = require('./utils');
const config = require('../config');
const valid = require('../validations');
const generateComponentsCache = require('../buildCommon/generateComponentsCache');
Expand All @@ -29,6 +30,12 @@ module.exports = ({ options, platform }) => {
config.set('componentsCache', generateComponentsCache({ context }));
let webpackConfig;
if (context.buildType === 'release') {
// In the release mode, the ./src/index.html file is minified. This process
// removes the <!-- css: redwood --> tag before the appropriate redwood css
// files link is injected. No tag, no injecting the link in ./web/index.html.
// So, we inject the link right before the minification process happens to ensure
// that the link is present in ./web/index.html.
webpackUtils.injectRedwoodThemeFileLink(context);
// eslint-disable-next-line global-require
webpackConfig = require('./webpack.production');
} else {
Expand Down
25 changes: 24 additions & 1 deletion lib/webpack/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
const path = require('path');
const fs = require('fs-extra');
const ojetUtils = require('../util');

const configPaths = ojetUtils.getConfiguredPaths();
Expand All @@ -17,6 +18,7 @@ const localComponentsPath = path.resolve(
const oracleJetDistPath = path.join(ojetUtils.getOraclejetPath(), 'dist');
const oracleJetDistCssPath = path.join(oracleJetDistPath, 'css');
const oracleJetDistJsLibsPath = path.join(oracleJetDistPath, 'js/libs');
const pathToSrcHTML = path.resolve(configPaths.src.common, 'index.html');
// eslint-disable-next-line no-useless-escape
const htmlTokenPattern = /(<!--\s*|@@)(css|js|img):([\w-\/]+)(\s*-->)?/g;
const htmlTokenResources = {
Expand Down Expand Up @@ -51,6 +53,25 @@ function isWebComponent(resourcePath) {
return component === undefined ? false : !!ojetUtils.getComponentsCache()[component];
}

function injectRedwoodThemeFileLink(context) {
if (context.opts.theme.name === 'redwood') {
const htmlContent = fs.readFileSync(pathToSrcHTML, { encoding: 'utf8' });
// eslint-disable-next-line no-useless-escape
const regex = new RegExp(/(<!--\s*|@@)(css|js|img):([\w\/]+)(\s*-->)?/, 'g');
const redwoodMinPath = htmlTokenReplacementFunction(undefined, undefined, 'css', 'redwood', '-->', undefined);
fs.writeFileSync(pathToSrcHTML, htmlContent.replace(regex, redwoodMinPath));
}
}

function restoreRedwoodTag(context) {
if (context.buildType === 'release') {
// eslint-disable-next-line quotes
const regex = new RegExp(/<link\s.*redwood-min.css">/, 'g');
const htmlContent = fs.readFileSync(pathToSrcHTML, { encoding: 'utf8' });
fs.writeFileSync(pathToSrcHTML, htmlContent.replace(regex, '<!-- css:redwood -->'));
}
}

module.exports = {
isWebComponent,
localComponentsPath,
Expand All @@ -59,5 +80,7 @@ module.exports = {
oracleJetDistCssPath,
oracleJetDistJsLibsPath,
htmlTokenPattern,
htmlTokenReplacementFunction
htmlTokenReplacementFunction,
injectRedwoodThemeFileLink,
restoreRedwoodTag
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oracle/oraclejet-tooling",
"version": "12.0.0",
"version": "12.1.0",
"license": "UPL-1.0",
"description": "Programmatic API to build and serve Oracle JET web and mobile applications",
"keywords": [
Expand Down

0 comments on commit 8dc7e93

Please sign in to comment.