@chatopera/bless
v1.2.6
Published
Hide your source code.
Downloads
16
Readme
Chatopera Bless
Node.js packaging utility to hide your source code.
source: nodejs-binary
Usage
Install
via npmjs registry
https://www.npmjs.com/package/@chatopera/bless
npm install -g @chatopera/bless
Use below command to verifiy installation.
Usage: dist [options]
Options:
-p, --projectdir <value> Project Path, *required
-l, --level [value] Mangling Level [union|minify|binary], optional, default binary
--clean [value] Clean up build files after generation, optional, default true
-h, --help output usage information
Project Structure
To package your project's source code to binary, define bless.json
under the project base dir, imagine the project has a structure like this.
purejs
├── main.js
├── bless.json
├── data
│ └── data.txt
├── lib
│ ├── a.js
│ ├── b.js
│ └── c.js
└── package.json
Note, purejs
is basedir, main.js
is main entry, bless.json
is configuration for bless
toolset.
Configure
A sample configuration file bless.json
.
{
"dist": {
"sources": ["main.js", "lib/**/*.js"],
"data": ["data/**/*", "data/**/.*"]
}
}
dist
is for target name
, a target is a collection of source codes and assets, it has a main entry that is executable. Target name is used as directory name to store Release files under bless-gen
.
sources
is a bunch of java script sources, the first element is for main entry of this application/library.
data
is the assets to copy into dist
folder.
Build
bless dist -p ${project path}
After the generation is done, check out ${project path}/bless-gen/${target name}
for the release file.
Note, during the generation, some build files
are generated first for compiling and linking, then package the sources
as binary
, build files
are deleted by default. In order to keep these files, --clean false
should be present, use command like bless dist --clean false -p ${project path}
.
There are three levels to hide the source codes, specify --level
with union
, minify
or binary
.
union
, make all source code into a solitary javascript file, the names for variables are not changed.minify
, make all source code into a solitary javascript file, the codes are uglified and minified.binary
, make all source code into a binary file, the codes are uglified and minified.
Checkout sample script.
Run
cd ${project path}/bless-gen/${target name}
npm i
node app.js
Samples
To get details about usage, check out samples in https://github.com/chatopera/bless-samples.
Known Issues
conflict with bless command in Mac OSX
Mac OSX has a command as bless
, to use bless
within node_modules
, set alias
in environment variables, for example:
alias bless='/Users/hain/.nvm/versions/node/v8.10.0/bin/bless'
Find your bless
command by where bless
.
empty folder in data
is not copyed
empty folder in data
section would be omitted.
require.main is not assigned value in main entry
So, this piece of code does not work to check main entry .
// on main entry
if (require.main === module) {
(async function() {
await main();
})();
}
Give credits to
License
Copyright 2019 北京华夏春松科技有限公司. All rights reserved.
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.