@neutralinojs/neu
Advanced tools
Comparing version 9.3.1 to 9.4.0
## What's new | ||
### Core: Plugins | ||
- Automatically re-install plugins when the neu CLI version is upgraded/downgraded via package managers. | ||
### DevOps: new test suite | ||
- Initiate a new Node.js-based test suite. | ||
### Core: downloader/builder | ||
- Support ARM (armhf/arm64) binaries. | ||
### Bugfixes/Improvements | ||
- Clean project files if the `neu create` command wan't successful. | ||
- Display an error message if the `neu build --copy-storage` fails due to missing `.storage` directory. | ||
- Support Darwin `arm64` binaries natively without binary translation (`x64` -> `arm64`). | ||
- Make the client library downloading process optional and support importing the client library via `@neutralinojs/lib`. | ||
- Download the module version of the client library based on the app configuration. | ||
Install the latest (`v9.3.1`) [npm package](https://www.npmjs.com/package/@neutralinojs/neu): | ||
Install the latest (`v9.4.0`) [npm package](https://www.npmjs.com/package/@neutralinojs/neu): | ||
@@ -13,0 +17,0 @@ ``` |
@@ -9,2 +9,14 @@ # Changelog | ||
## v9.4.0 | ||
### DevOps: new test suite | ||
- Initiate a new Node.js-based test suite. | ||
### Bugfixes/Improvements | ||
- Clean project files if the `neu create` command wan't successful. | ||
- Display an error message if the `neu build --copy-storage` fails due to missing `.storage` directory. | ||
- Support Darwin `arm64` binaries natively without binary translation (`x64` -> `arm64`). | ||
- Make the client library downloading process optional and support importing the client library via `@neutralinojs/lib`. | ||
- Download the module version of the client library based on the app configuration. | ||
## v9.3.1 | ||
@@ -11,0 +23,0 @@ |
{ | ||
"name": "@neutralinojs/neu", | ||
"version": "9.3.1", | ||
"version": "9.4.0", | ||
"description": "neu CLI for Neutralinojs", | ||
@@ -5,0 +5,0 @@ "main": "./bin/neu.js", |
@@ -1,4 +0,8 @@ | ||
# neu CLI | ||
<div align="center"><img src="images/logo.png"/></div> | ||
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/neutralinojs/neutralinojs-cli)](https://github.com/neutralinojs/neutralinojs-cli/releases) | ||
![npm](https://img.shields.io/npm/v/@neutralinojs/neu) | ||
![npm](https://img.shields.io/npm/dt/@neutralinojs/neu) | ||
[![GitHub last commit](https://img.shields.io/github/last-commit/neutralinojs/neutralinojs-cli.svg)](https://github.com/neutralinojs/neutralinojs-cli/commits/main) | ||
![Build status](https://github.com/neutralinojs/neutralinojs-cli/actions/workflows/test_suite.yml/badge.svg) | ||
@@ -5,0 +9,0 @@ The official CLI of Neutralinojs. See neu CLI [documentation](https://neutralino.js.org/docs/cli/neu-cli/) for more details. |
@@ -17,3 +17,7 @@ const utils = require('../utils'); | ||
console.log(`Neutralinojs binaries: ${utils.getVersionTag(configObj.cli.binaryVersion)}`); | ||
console.log(`Neutralinojs client: ${utils.getVersionTag(configObj.cli.clientVersion)}`); | ||
let clientVersion = configObj.cli.clientVersion ? utils.getVersionTag(configObj.cli.clientVersion) : | ||
'Installed from a package manager'; | ||
console.log(`Neutralinojs client: ${clientVersion}`); | ||
if(configObj.version) { | ||
@@ -20,0 +24,0 @@ console.log(`Project version: v${configObj.version}`); |
module.exports = { | ||
remote: { | ||
binaries: { | ||
url: "https://github.com/neutralinojs/neutralinojs/releases/download/{tag}/neutralinojs-{tag}.zip" | ||
}, | ||
client: { | ||
url: "https://github.com/neutralinojs/neutralino.js/releases/download/{tag}/neutralino.js" | ||
}, | ||
binariesUrl:"https://github.com/neutralinojs/neutralinojs/releases/download/{tag}/neutralinojs-{tag}.zip", | ||
clientUrlPrefix: "https://github.com/neutralinojs/neutralino.js/releases/download/{tag}/neutralino.", | ||
templateUrl: "https://github.com/{template}/archive/main.zip" | ||
@@ -13,3 +9,3 @@ }, | ||
configFile: "neutralino.config.json", | ||
clientLibrary: "neutralino.js", | ||
clientLibraryPrefix: "neutralino.", | ||
resourceFile: "resources.neu", | ||
@@ -24,3 +20,4 @@ authFile: ".tmp/auth_info.json", | ||
darwin: { | ||
x64: "neutralino-mac_x64" | ||
x64: "neutralino-mac_x64", | ||
arm64: "neutralino-mac_arm64" | ||
}, | ||
@@ -34,4 +31,5 @@ win32: { | ||
misc: { | ||
hotReloadPatchRegex: /(<script.*src=")(.*neutralino.js)(".*><\/script>)/g | ||
hotReloadLibPatchRegex: /(<script.*src=")(.*neutralino.js)(".*><\/script>)/g, | ||
hotReloadGlobPatchRegex: /(<script.*src=")(.*__neutralino_globals.js)(".*><\/script>)/g | ||
} | ||
}; |
@@ -14,3 +14,4 @@ const fse = require('fs-extra'); | ||
const extensionsDir = utils.trimPath(configObj.cli.extensionsPath); | ||
const clientLibrary = utils.trimPath(configObj.cli.clientLibrary); | ||
const clientLibrary = configObj.cli.clientLibrary ? utils.trimPath(configObj.cli.clientLibrary) | ||
: null; | ||
const icon = utils.trimPath(configObj.modes.window.icon); | ||
@@ -27,3 +28,5 @@ const binaryName = configObj.cli.binaryName; | ||
await fse.copy(`${constants.files.configFile}`, `.tmp/${constants.files.configFile}`, {overwrite: true}); | ||
await fse.copy(`./${clientLibrary}`, `.tmp/${clientLibrary}`, {overwrite: true}); | ||
if(clientLibrary) { | ||
await fse.copy(`./${clientLibrary}`, `.tmp/${clientLibrary}`, {overwrite: true}); | ||
} | ||
await fse.copy(`./${icon}`, `.tmp/${icon}`, {overwrite: true}); | ||
@@ -57,3 +60,9 @@ | ||
utils.log('Copying storage data...'); | ||
fse.copySync(`.storage`,`dist/${binaryName}/.storage`); | ||
try { | ||
fse.copySync('.storage',`dist/${binaryName}/.storage`); | ||
} | ||
catch(err) { | ||
utils.error('Unable to copy storage data from the .storage directory. Please check if the directory exists'); | ||
process.exit(1); | ||
} | ||
} | ||
@@ -60,0 +69,0 @@ |
const process = require('process'); | ||
const fs = require('fs'); | ||
const fse = require('fs-extra'); | ||
const config = require('../modules/config'); | ||
@@ -28,2 +29,3 @@ const downloader = require('./downloader'); | ||
' Please check your internet connection and template URLs.'); | ||
fse.removeSync(`../${binaryName}`); | ||
process.exit(1); | ||
@@ -30,0 +32,0 @@ } |
@@ -12,10 +12,18 @@ const fs = require('fs'); | ||
let version = configObj.cli.binaryVersion; | ||
return constants.remote.binaries.url | ||
return constants.remote.binariesUrl | ||
.replace(/{tag}/g, utils.getVersionTag(version)); | ||
} | ||
let getScriptExtension = () => { | ||
const configObj = config.get(); | ||
let clientLibrary = configObj.cli.clientLibrary; | ||
return clientLibrary.includes('.mjs') ? 'mjs' : 'js'; | ||
} | ||
let getClientDownloadUrl = () => { | ||
const configObj = config.get(); | ||
let version = configObj.cli.clientVersion; | ||
return constants.remote.client.url | ||
let clientLibrary = configObj.cli.clientLibrary; | ||
let scriptUrl = constants.remote.clientUrlPrefix + getScriptExtension(); | ||
return scriptUrl | ||
.replace(/{tag}/g, utils.getVersionTag(version)); | ||
@@ -50,3 +58,3 @@ } | ||
fs.mkdirSync('.tmp', { recursive: true }); | ||
const file = fs.createWriteStream('.tmp/neutralino.js'); | ||
const file = fs.createWriteStream('.tmp/neutralino.' + getScriptExtension()); | ||
utils.log('Downloading the Neutralinojs client..'); | ||
@@ -109,8 +117,14 @@ https.get(getClientDownloadUrl(), function (response) { | ||
const configObj = config.get(); | ||
if(!configObj.cli.clientLibrary) { | ||
utils.log(`neu CLI won't download the client library --` + | ||
` download @neutralinojs/lib from your Node package manager.`); | ||
return; | ||
} | ||
const clientLibrary = utils.trimPath(configObj.cli.clientLibrary); | ||
await downloadClientFromRelease(); | ||
utils.log('Finalizing and cleaning temp. files...'); | ||
fse.copySync(`.tmp/${constants.files.clientLibrary}`, `./${clientLibrary}`); | ||
fse.copySync(`.tmp/${constants.files.clientLibraryPrefix + getScriptExtension()}` | ||
, `./${clientLibrary}`); | ||
utils.clearCache(); | ||
} | ||
@@ -7,4 +7,6 @@ const fs = require('fs'); | ||
const HOT_REL_PATCH_REGEX = constants.misc.hotReloadPatchRegex; | ||
const HOT_REL_LIB_PATCH_REGEX = constants.misc.hotReloadLibPatchRegex; | ||
const HOT_REL_GLOB_PATCH_REGEX = constants.misc.hotReloadGlobPatchRegex; | ||
let originalClientLib = null; | ||
let originalGlobals = null; | ||
@@ -17,3 +19,3 @@ async function makeClientLibUrl(port) { | ||
.find((file) => /neutralino\.js$/.test(file)) | ||
.replace(/\\/g, '/'); //Fix path on windows; | ||
?.replace(/\\/g, '/'); //Fix path on windows; | ||
@@ -32,9 +34,13 @@ let url = `http://localhost:${port}`; | ||
function patchHTMLFile(clientLib) { | ||
function makeGlobalsUrl(port) { | ||
return `http://localhost:${port}/__neutralino_globals.js`; | ||
} | ||
function patchHTMLFile(scriptFile, regex) { | ||
let configObj = config.get(); | ||
let patchFile = configObj.cli.frontendLibrary.patchFile.replace(/^\//, ''); | ||
let html = fs.readFileSync(patchFile, 'utf8'); | ||
let matches = HOT_REL_PATCH_REGEX.exec(html); | ||
let matches = regex.exec(html); | ||
if(matches) { | ||
html = html.replace(HOT_REL_PATCH_REGEX, `$1${clientLib}$3`); | ||
html = html.replace(regex, `$1${scriptFile}$3`); | ||
fs.writeFileSync(patchFile, html); | ||
@@ -47,4 +53,9 @@ return matches[2]; | ||
module.exports.bootstrap = async (port) => { | ||
let clientLibUrl = await makeClientLibUrl(port); | ||
originalClientLib = patchHTMLFile(clientLibUrl); | ||
let configObj = config.get(); | ||
if(configObj.cli.clientLibrary) { | ||
let clientLibUrl = await makeClientLibUrl(port); | ||
originalClientLib = patchHTMLFile(clientLibUrl, HOT_REL_LIB_PATCH_REGEX); | ||
} | ||
let globalsUrl = await makeGlobalsUrl(port); | ||
originalGlobals = patchHTMLFile(globalsUrl, HOT_REL_GLOB_PATCH_REGEX); | ||
utils.warn(`Hot reload patch was applied successfully. ` + | ||
@@ -58,5 +69,8 @@ `Please avoid sending keyboard interrupts.`); | ||
if(originalClientLib) { | ||
patchHTMLFile(originalClientLib); | ||
utils.log('Hot reload patch was reverted.'); | ||
patchHTMLFile(originalClientLib, HOT_REL_LIB_PATCH_REGEX); | ||
} | ||
if(originalGlobals) { | ||
patchHTMLFile(originalGlobals, HOT_REL_GLOB_PATCH_REGEX); | ||
} | ||
utils.log('Hot reload patch was reverted.'); | ||
} |
@@ -12,8 +12,2 @@ const { spawn } = require('child_process'); | ||
// Use x64 binary for M1 chip (arm64) | ||
// Translation is handled by macOS | ||
if(platform == 'darwin' && arch == 'arm64') { | ||
arch = 'x64'; | ||
} | ||
if(!(platform in constants.files.binaries)) | ||
@@ -20,0 +14,0 @@ return ''; |
@@ -1,2 +0,1 @@ | ||
const path = require('path'); | ||
@@ -3,0 +2,0 @@ const { exec } = require('child_process'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182978
45
2694
34
16
4