Skip to content

Commit

Permalink
Release 10.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
benm071 committed Jan 15, 2021
1 parent 84cee49 commit cfa6b66
Show file tree
Hide file tree
Showing 69 changed files with 565 additions and 369 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to oraclejet-tooling

*Copyright (c) 2014, 2020 Oracle and/or its affiliates
*Copyright (c) 2014, 2021 Oracle and/or its affiliates
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/*

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# oraclejet-tooling

Copyright (c) 2020 Oracle and/or its affiliates.
Copyright (c) 2021 Oracle and/or its affiliates.

Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# @oracle/oraclejet-tooling 9.2.0
# @oracle/oraclejet-tooling 10.0.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=jet920&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=jet1000&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
[CONTRIBUTING](https://github.com/oracle/oraclejet-tooling/blob/master/CONTRIBUTING.md)
for details.

## [License](https://github.com/oracle/oraclejet-tooling/blob/master/LICENSE)
Copyright (c) 2020 Oracle and/or its affiliates and released under the
Copyright (c) 2021 Oracle and/or its affiliates and released under the
[Universal Permissive License (UPL)](https://oss.oracle.com/licenses/upl/), Version 1.0
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 ##

### 9.2.0
### 10.0.0
* No changes

### 5.2.0
Expand Down
2 changes: 1 addition & 1 deletion config/eslintcustom.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
2 changes: 1 addition & 1 deletion hooks/jetAfterPrepare.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
2 changes: 1 addition & 1 deletion hooks/jetInjector.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
2 changes: 1 addition & 1 deletion lib/add.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env node
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
3 changes: 1 addition & 2 deletions lib/addpcss.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env node
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand All @@ -27,7 +27,6 @@ module.exports = function () {

return util.spawn('npm', ['install',
`node-sass@${sassVer}`,
'[email protected]',
'[email protected]',
'[email protected]',
'--save-dev=true']);
Expand Down
82 changes: 82 additions & 0 deletions lib/addpwa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#! /usr/bin/env node
/**
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
*/

'use strict';

/**
* ## Dependencies
*/

const fs = require('fs-extra');
const path = require('path');
const CONSTANTS = require('./constants');
/**
* #addpwa
*
* @public
* @returns {Promise}
*/

module.exports = function () {
return new Promise((resolve) => {
// eslint-disable-next-line global-require
const appName = path.basename(process.cwd());
const appNameRegex = new RegExp('@AppName@', 'g');
const pathToApp = path.join('src');
const pathToIndexHtml = path.join(pathToApp, 'index.html');
const pathToServiceWorkerTemplates = CONSTANTS.PATH_TO_PWA_TEMPLATES;
// 1. read index.html
const indexHtmlString = fs.readFileSync(
pathToIndexHtml,
{ encoding: 'utf-8' }
);
// 2. read sw.txt, replace app name token, write to app as js file
const swJsString = fs.readFileSync(
path.join(pathToServiceWorkerTemplates, 'sw.txt'),
{ encoding: 'utf-8' }
);
const pathToAppSw = path.join(pathToApp, 'sw.js');
if (fs.pathExistsSync(pathToAppSw)) {
fs.renameSync(pathToAppSw, path.join(pathToApp, 'sw_old.js'));
}
fs.outputFileSync(
pathToAppSw,
swJsString.replace(appNameRegex, appName)
);
// 3. read manifest.json, replace app name token, write to app
const manifestJsonString = fs.readFileSync(
path.join(pathToServiceWorkerTemplates, 'manifest.json'),
{ encoding: 'utf-8' }
);
const pathToAppManifest = path.join(pathToApp, 'manifest.json');
if (fs.pathExistsSync(pathToAppManifest)) {
fs.renameSync(pathToAppManifest, path.join(pathToApp, 'manifest_old.json'));
}
fs.outputFileSync(
path.join(pathToApp, 'manifest.json'),
manifestJsonString.replace(appNameRegex, appName)
);
// 4. copy swInit.txt and add it to end of body tag index.html, add <link>
// to end of header tag in index.html and update
const swInitString = fs.readFileSync(
path.join(pathToServiceWorkerTemplates, 'swInit.txt'),
{ encoding: 'utf-8' }
);
fs.outputFileSync(
pathToIndexHtml,
indexHtmlString.replace(
new RegExp('</head>', 'g'),
'<link rel="manifest" href="manifest.json">\n</head>'
).replace(
new RegExp('</body>', 'g'),
`${swInitString.replace(appNameRegex, appName)}\n</body>`
)
);
resolve();
});
};
2 changes: 1 addition & 1 deletion lib/addsass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env node
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
4 changes: 2 additions & 2 deletions lib/addtypescript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env node
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down Expand Up @@ -34,7 +34,7 @@ const path = require('path');
function installTypescipt() {
return new Promise((resolve) => {
util.log('Installing Typescript');
exec(`npm install typescript@${CONSTANTS.TYPESCRIPT_VERSION} --save-dev=true`, {
exec(`npm install typescript@${CONSTANTS.TYPESCRIPT_VERSION} --save-dev --save-exact`, {
env: {
...process.env,
// speed up npm install when on vpn
Expand Down
2 changes: 1 addition & 1 deletion lib/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand Down
60 changes: 38 additions & 22 deletions lib/buildCommon.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
Copyright (c) 2015, 2020, Oracle and/or its affiliates.
Copyright (c) 2015, 2021, Oracle and/or its affiliates.
Licensed under The Universal Permissive License (UPL), Version 1.0
as shown at https://oss.oracle.com/licenses/upl/
Expand All @@ -13,6 +13,7 @@ const requirejs = require('requirejs');
const util = require('./util');
const config = require('./config');
const npmCopy = require('./npmCopy');
const injectorUtil = require('./injectorUtil');
const mainJsInjector = require('./mainJsInjector');
const indexHtmlInjector = require('./indexHtmlInjector');
const svg = require('./svg');
Expand Down Expand Up @@ -105,15 +106,18 @@ function _copyDefaultResourcesToStaging(theme, stagingPath, themeName) {
const srcBase = `${config('paths').staging.themes}/${themeName}`;
const destBase = util.destPath(path.join(stagingPath, config('paths').src.styles, themeName, util.getJETVersion()));

const commonSrc = path.join(srcBase, CONSTANTS.COMMON_THEME_DIRECTORY);
const defaultFontsSrc = path.join(srcBase, theme.platform, 'fonts');
const defaultImagesSrc = path.join(srcBase, theme.platform, 'images');

const commonDest = path.join(destBase, CONSTANTS.COMMON_THEME_DIRECTORY);
const defaultFontsDest = path.join(destBase, theme.platform, 'fonts');
const defaultImagesDest = path.join(destBase, theme.platform, 'images');

fs.copySync(commonSrc, commonDest);
if (config('defaultTheme') === CONSTANTS.DEFAULT_THEME && themeName !== CONSTANTS.DEFAULT_PCSS_THEME) {
const commonSrc = path.join(srcBase, CONSTANTS.COMMON_THEME_DIRECTORY);
const commonDest = path.join(destBase, CONSTANTS.COMMON_THEME_DIRECTORY);
fs.copySync(commonSrc, commonDest);
}

fs.copySync(defaultFontsSrc, defaultFontsDest);
fs.copySync(defaultImagesSrc, defaultImagesDest);
}
Expand Down Expand Up @@ -167,7 +171,7 @@ function _copyFilesExcludeScss(srcBase, destBase) {
});
}
} catch (err) {
util.log(err);
util.log.error(err);
}
}

Expand Down Expand Up @@ -221,7 +225,7 @@ function _copyThemesToStaging(context) {
const rwood = Object.assign({},
{ name: 'redwood', platform: 'web', compile: false, version: util.getJETVersion() });

if (config('defaultTheme') === CONSTANTS.DEFAULT_PCSS_THEME) {
if (opts.theme.cssGeneratedType === 'add-on' || config('defaultTheme') === CONSTANTS.DEFAULT_PCSS_THEME) {
const rwsrc = _getThemeSrcPath(rwood, ext, livereload);
const rwdest = _getThemeDestPath(rwood, stgPath, ext, livereload, platform, opts.destination);
fs.copySync(rwsrc, rwdest);
Expand All @@ -232,7 +236,7 @@ function _copyThemesToStaging(context) {
if ((theme.name !== CONSTANTS.DEFAULT_THEME || theme.name !== CONSTANTS.DEFAULT_PCSS_THEME)
&& !livereload) {
_copySrcResourcesToThemes(theme);
if (config('defaultTheme') === CONSTANTS.DEFAULT_PCSS_THEME) {
if (opts.theme.cssGeneratedType === 'add-on' || config('defaultTheme') === CONSTANTS.DEFAULT_PCSS_THEME) {
_copySrcResourcesToThemes(rwood);
}
if (!util.getInstalledCssPackage()) {
Expand Down Expand Up @@ -291,6 +295,7 @@ function _requireJsInvoker(context) {
resolve(context);
}, (err) => {
util.log(err);
util.log.error(err);
reject(err);
});
});
Expand All @@ -314,6 +319,7 @@ function _requireJsInvokerEs5(context) {
}, (err) => {
context.opts.isRequireJsEs5 = false; // eslint-disable-line no-param-reassign
util.log(err);
util.log.error(err);
reject(err);
});
});
Expand Down Expand Up @@ -579,11 +585,6 @@ module.exports = {
},

css: function _compileCss(context) {
const theme = (context.opts.theme) ? context.opts.theme.name : config('defaultTheme');
const csstype = (context.opts.defaultCssvars) ? context.opts.defaultCssvars : config('defaultCssvars');
const cssVarsDestPath = path.resolve(config('paths').src.common, 'themes', theme, 'web', `_${theme}.cssvars.settings.scss`);
const pcssTheme = fs.existsSync(util.destPath(cssVarsDestPath));

if ((context.opts.theme.compile === false && context.opts.sassCompile === false)
|| context.opts.nosass) {
util.log('SCSS Compilation skipped...');
Expand Down Expand Up @@ -611,11 +612,6 @@ module.exports = {
}

if (!util.getInstalledCssPackage()) {
if (!pcssTheme || theme === CONSTANTS.DEFAULT_THEME) {
if (csstype === 'enabled' && theme !== CONSTANTS.DEFAULT_PCSS_THEME) {
util.log.error('Alta theme cannot have defaultCssvars:enabled in oraclejetconfig.json, enable supported only for pcss themes.');
}
}
util.log('Compiling sass...');
return new Promise((resolve, reject) => {
if (context.opts.sassCompile === false && svg !== true) {
Expand Down Expand Up @@ -658,14 +654,32 @@ module.exports = {
});
},

// Copy the standard es5-deciding main.js file for release builds (to choose the proper bundle)
copyMainJs: function _copyMainJs(context) {
util.log('Copying main.js');
// Modify the standard es5-deciding main.js file for release builds (to choose the proper bundle)
modifyMainJs: function _copyMainJs(context) {
util.log('Modifying main.js');
const dest = _getName(context.opts.stagingPath, 'main.js');
let mainJs = util.readFileSync(dest);

const injectConfig = context.opts.injectPaths;
const startTag = injectConfig.startTag;
const endTag = injectConfig.endTag;
const pattern = injectorUtil.getInjectorTagsRegExp(startTag, endTag);
const lineEnding = /\r\n/.test(String(mainJs)) ? '\r\n' : '\n';

// actual injection
const emptyPaths = '{}';
mainJs = mainJs.replace(pattern, () =>
startTag + lineEnding + emptyPaths + lineEnding + endTag
);

// Need to replace the require([]) line with just one that refers to bundles
const requirePattern = /}\s*\(\s*\)\s*\)\s*;[^]*require\s*\(\s*\[[^]+\][^]+\)/gi;
const newRequireCode = "var bundle = 'bundle' + (_ojNeedsES5 ? '_es5' : '');\nrequire([bundle], function () {});}());";
mainJs = mainJs.replace(requirePattern, newRequireCode);

return new Promise((resolve) => {
fs.copySync(path.resolve(__dirname, 'main.js'), dest, { overwrite: true });
util.log('Copy main.js finished');
fs.outputFileSync(dest, mainJs);
util.log('Modify main.js finished');
resolve(context);
});
},
Expand Down Expand Up @@ -922,6 +936,7 @@ module.exports = {
})
.catch((err) => {
util.log(err);
util.log.error(err);
reject2(err);
});
}
Expand All @@ -930,6 +945,7 @@ module.exports = {
resolve(data);
}).catch((err) => {
util.log(err);
util.log.error(err);
reject(err);
});
} // else components.length === 0
Expand Down
Loading

0 comments on commit cfa6b66

Please sign in to comment.