Repository: nowa-webpack/nowa
Branch: master
Commit: 8da38f00b925
Files: 12
Total size: 11.7 KB
Directory structure:
gitextract_qmgksik3/
├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── bin/
│ ├── nowa
│ └── nowa.cmd
├── index.js
├── package.json
├── src/
│ ├── check.js
│ ├── index.js
│ └── update-notifier.js
└── uninstall.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .editorconfig
================================================
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
================================================
FILE: .gitignore
================================================
node_modules
~*
*~
.DS_Store
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2016 nowa
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# nowa
[](https://npmjs.org/package/nowa)
nowa webpack solution
----
## Feature
- Generate a [webpack](https://github.com/webpack/webpack) based boilerplate.
- Run a local server for web developer, support proxy and HMR.
- Easy to use and customize third-party UI components.
- Support customized webpack.config.js.
- Support `buildvars` to automatically output bundles with different varible combinations.
Checkout [https://nowa-webpack.github.io/](https://nowa-webpack.github.io/) for more information.
## Install
- Install nowa
```bash
$ npm i nowa -g
```
- Install all frequently-used nowa plugins ([build](https://github.com/nowa-webpack/nowa-build), [init](https://github.com/nowa-webpack/nowa-init), [lib](https://github.com/nowa-webpack/nowa-lib), [server](https://github.com/nowa-webpack/nowa-server))
```bash
$ nowa install
```
> You can install any plugin by `nowa install <name>`.
> Find more plugins, visit [here](https://www.npmjs.com/search?q=nowa-).
## Usage
- Generate a boilerplate.
```bash
$ mkdir test && cd test
$ nowa init uxcore
```
- Start a local dev server.
```bash
$ nowa server
```
- Build project.
```bash
$ nowa build
```
- Build libraries.
```bash
$ nowa lib
```
================================================
FILE: bin/nowa
================================================
#!/usr/bin/env node
module.exports = require('../');
================================================
FILE: bin/nowa.cmd
================================================
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\nowa\bin\nowa" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\nowa\bin\nowa" %*
)
================================================
FILE: index.js
================================================
#!/usr/bin/env node
module.exports = require('./src');
================================================
FILE: package.json
================================================
{
"name": "nowa",
"version": "1.2.2",
"description": "nowa webpack solution",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"preuninstall": "node ./uninstall.js"
},
"repository": {
"type": "git",
"url": "https://github.com/nowa-webpack/nowa.git"
},
"keywords": [
"nowa",
"webpack",
"server",
"builder"
],
"author": "gbk <ck0123456@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/nowa-webpack/nowa/issues"
},
"homepage": "https://github.com/nowa-webpack/nowa#readme",
"dependencies": {
"chalk": "~1.1.3",
"commander": "~2.9.0",
"nowa-install": "^1.0.0",
"nowa-plugin": "^1.0.0",
"package-json": "~2.3.2",
"resolve": "~1.1.7",
"semver": "~5.1.0"
},
"bin": {
"nowa": "./bin/nowa"
},
"engines": {
"node": ">=4.0.0",
"npm": "^3.0.0"
}
}
================================================
FILE: src/check.js
================================================
/*
* @Author: gbk
* @Date: 2016-06-25 17:44:38
* @Last Modified by: gbk
* @Last Modified time: 2016-06-25 22:26:03
*/
'use strict';
var os = require('os');
var fs = require('fs');
var path = require('path');
var packageJson = require('package-json');
var configRoot = path.join(os.homedir(), '.nowa');
var versionsPath = path.join(configRoot, 'latest-versions.json');
// tasks definiation
var majorVersion = process.argv[2].split('.')[0];
var tasks = process.argv.slice(3).map(function(command) {
return packageJson(command, majorVersion);
});
tasks.push(packageJson('nowa', 'latest'))
tasks.push(new Promise(function(resolve) {
fs.mkdir(configRoot, resolve);
}));
// run tasks
new Promise(function(resolve, reject) {
fs.readFile(versionsPath, 'utf-8', function(err, data) {
if (data) {
data = JSON.parse(data);
// check interval by 1 day
if (Date.now() - data.update > 3600000 * 24) {
resolve(Promise.all(tasks));
} else {
reject();
}
} else {
resolve(Promise.all(tasks));
}
});
}).then(function(pkgs) {
// write to versions store
var versions = {};
pkgs.forEach(function(pkg) {
versions[pkg.name] = pkg.version;
});
fs.writeFile(versionsPath, JSON.stringify({
versions: versions,
update: Date.now()
}));
});
================================================
FILE: src/index.js
================================================
/*
* @Author: gbk
* @Date: 2016-04-11 16:43:10
* @Last Modified by: gbk
* @Last Modified time: 2017-03-23 21:33:26
*/
'use strict';
var fs = require('fs');
var path = require('path');
var resolve = require('resolve');
var program = require('commander');
var chalk = require('chalk');
var semver = require('semver');
var updateNotifier = require('./update-notifier');
var pkg = require('../package.json');
var argvs = process.argv;
var command = argvs[2];
// check nodejs version
if (!semver.satisfies(process.version, pkg.engines.node)) {
console.log(chalk.red.bold('Require nodejs version ' + pkg.engines.node + ', current ' + process.version));
console.log('Download the latest nodejs here ' + chalk.green('https://nodejs.org/en/download/'));
process.exit();
}
// program definiation
program
.version(pkg.version)
.usage('<command> [options]');
// dirs to find plugins
var moduleDirs = [
path.join(__dirname, '..', 'node_modules'),
path.join(__dirname, '..', '..')
];
program._moduleDirs = moduleDirs;
// locate the plugin
var pluginPath = findPluginPath(command);
if (pluginPath) { // plugin found
// check update of current command
updateNotifier(pkg.version, 'nowa-' + command);
// regist current plugin
var pluginDef = require(pluginPath);
var plugin = program.command(pluginDef.command || command);
if (pluginDef.description) {
plugin.description(pluginDef.description);
}
// set options
if (pluginDef.options) {
// default options in abc.json
var defaultOpts = loadDefaultOpts(process.cwd(), 'abc.json');
var optNameReg = /\-\-(\w+)/;
pluginDef.options.forEach(function(optArgs) {
if (optArgs) {
plugin.option.apply(plugin, optArgs);
// replace default value with options in abc.json
var matches = optNameReg.exec(optArgs[0]);
if (matches && matches[1] in defaultOpts) {
plugin[matches[1]] = defaultOpts[matches[1]]
}
}
});
}
// set action
if (pluginDef.action) {
plugin.action(function(cmd, opts) {
if (cmd instanceof program.Command) {
opts = cmd;
cmd = '';
}
opts = opts || {};
// run plugin action
if (cmd) {
pluginDef.action.call(this, cmd, opts);
} else {
pluginDef.action.call(this, opts);
}
});
}
} else if (!command) { // plugin not found
var plugins;
var pluginPool = {};
moduleDirs.forEach(function(modulesDir, index) {
// search plugins
plugins = fs.readdirSync(modulesDir).filter(function(name) {
// filter by name
return /^nowa\-\w+$/.test(name);
});
// regist all the plugins
plugins.forEach(function(name) {
// ensure local plugins not be overridden
if (!pluginPool[name]) {
pluginPool[name] = true;
// regist a plugin for help
var pluginPkg = require(path.join(modulesDir, name, 'package.json'));
program
.command(name.substring(5))
.description(pluginPkg.description + chalk.green(' (v' + pluginPkg.version + ')'));
}
});
});
// check update of all plugins
updateNotifier.apply(null, [ pkg.version ].concat(plugins));
}
// parse command line arguments
program.parse(argvs);
// output help if no argv specified
if (!argvs.slice(2).length) {
program.outputHelp();
}
// locate the plugin by command
function findPluginPath(command) {
if (command && /^\w+$/.test(command)) {
try {
return resolve.sync('nowa-' + command, {
paths: moduleDirs
});
} catch (e) {
console.log('');
console.log(' ' + chalk.green.bold(command) + ' command is not installed.');
console.log(' You can try to install it by ' + chalk.blue.bold('nowa install ' + command) + '.');
console.log('');
}
}
}
// load default options
function loadDefaultOpts(startDir, configFile) {
try {
return require(path.join(startDir, configFile)).options || {};
} catch (e) {
var dir = path.dirname(startDir);
if (dir === startDir) {
return {};
}
return loadDefaultOpts(dir, configFile);
}
}
================================================
FILE: src/update-notifier.js
================================================
/*
* @Author: gbk
* @Date: 2016-06-25 12:42:56
* @Last Modified by: gbk
* @Last Modified time: 2017-06-21 20:53:33
*/
'use strict';
var os = require('os');
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var chalk = require('chalk');
var semver = require('semver');
module.exports = function() {
// do not show update tip inside nowa-gui
if (process.env.NOWA_GUI) {
return;
}
// check for nowa-gui installation
try {
fs.statSync(path.join(os.homedir(), '.nowa-gui', 'user_config.json'))
} catch (e) {
console.log(
chalk.yellow(
'\n Nowa GUI for all platform is available now!' +
'\n You can download it here:' +
'\n https://nowa-webpack.github.io/')
);
}
// read latest versions
var versionsFile = path.join(os.homedir(), '.nowa', 'latest-versions.json');
var store = {};
try {
store = JSON.parse(fs.readFileSync(versionsFile, 'utf-8'));
} catch(e) {}
var versions = store.versions || {};
// compare versions and show tip
var isTipShow = false;
var argvs = Array.prototype.slice.call(arguments, 0);
argvs.slice(1).concat([ 'nowa' ]).forEach(function(plugin) {
try {
var pkg = require(path.join(__dirname, '..', '..', plugin, 'package.json'));
if (versions[plugin] && semver.lt(pkg.version, versions[plugin])) {
if (plugin === 'nowa') {
// do not show nowa update tip if any plugins need update
if (!isTipShow) {
console.log(
chalk.yellow(
'\n Update available: ' +
plugin + '@' + versions[plugin] + ' (Current: ' + pkg.version + ')' +
'\n Run `npm i nowa -g` to update.')
);
}
} else {
console.log(
chalk.yellow(
'\n Update available: ' +
plugin + '@' + versions[plugin] + ' (Current: ' + pkg.version + ')' +
'\n Run `nowa install ' + plugin.substring(5) + '` to update.')
);
}
isTipShow = true;
}
} catch(e) {
}
});
// fetch latest versions
spawn(process.execPath, [
path.join(__dirname, 'check')
].concat(argvs), {
detached: true,
stdio: 'ignore'
}).unref();
};
================================================
FILE: uninstall.js
================================================
/*
* @Author: gbk
* @Date: 2016-06-26 10:38:07
* @Last Modified by: gbk
* @Last Modified time: 2017-03-20 10:51:44
*/
'use strict';
var os = require('os');
var path = require('path');
var exec = require('child_process').execSync;
var configRoot = path.join(os.homedir(), '.nowa');
var rimrafPath = path.join(configRoot, 'install', '.bin', 'rimraf');
var installMods = path.join(configRoot, 'install', '*');
exec('node ' + rimrafPath + ' ../nowa-* ' + installMods);
gitextract_qmgksik3/ ├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── bin/ │ ├── nowa │ └── nowa.cmd ├── index.js ├── package.json ├── src/ │ ├── check.js │ ├── index.js │ └── update-notifier.js └── uninstall.js
SYMBOL INDEX (2 symbols across 1 files)
FILE: src/index.js
function findPluginPath (line 137) | function findPluginPath(command) {
function loadDefaultOpts (line 153) | function loadDefaultOpts(startDir, configFile) {
Condensed preview — 12 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (13K chars).
[
{
"path": ".editorconfig",
"chars": 171,
"preview": "root = true\n\n[*]\nindent_style = space\nindent_size = 2\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newli"
},
{
"path": ".gitignore",
"chars": 29,
"preview": "node_modules\n~*\n*~\n.DS_Store\n"
},
{
"path": "LICENSE",
"chars": 1071,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2016 nowa\n\nPermission is hereby granted, free of charge, to any person obtaining a "
},
{
"path": "README.md",
"chars": 1280,
"preview": "# nowa\n\n[](https://npmjs.org/package/nowa)\n\nnowa webpack"
},
{
"path": "bin/nowa",
"chars": 54,
"preview": "#!/usr/bin/env node\n\nmodule.exports = require('../');\n"
},
{
"path": "bin/nowa.cmd",
"chars": 174,
"preview": "@IF EXIST \"%~dp0\\node.exe\" (\r\n \"%~dp0\\node.exe\" \"%~dp0\\..\\nowa\\bin\\nowa\" %*\r\n) ELSE (\r\n @SETLOCAL\r\n @SET PATHEXT=%PA"
},
{
"path": "index.js",
"chars": 56,
"preview": "#!/usr/bin/env node\n\nmodule.exports = require('./src');\n"
},
{
"path": "package.json",
"chars": 912,
"preview": "{\n \"name\": \"nowa\",\n \"version\": \"1.2.2\",\n \"description\": \"nowa webpack solution\",\n \"main\": \"index.js\",\n \"scripts\": {"
},
{
"path": "src/check.js",
"chars": 1318,
"preview": "/*\n* @Author: gbk\n* @Date: 2016-06-25 17:44:38\n* @Last Modified by: gbk\n* @Last Modified time: 2016-06-25 22:26:03\n*"
},
{
"path": "src/index.js",
"chars": 4122,
"preview": "/*\n* @Author: gbk\n* @Date: 2016-04-11 16:43:10\n* @Last Modified by: gbk\n* @Last Modified time: 2017-03-23 21:33:26\n*"
},
{
"path": "src/update-notifier.js",
"chars": 2300,
"preview": "/*\n* @Author: gbk\n* @Date: 2016-06-25 12:42:56\n* @Last Modified by: gbk\n* @Last Modified time: 2017-06-21 20:53:33\n*"
},
{
"path": "uninstall.js",
"chars": 472,
"preview": "/*\n* @Author: gbk\n* @Date: 2016-06-26 10:38:07\n* @Last Modified by: gbk\n* @Last Modified time: 2017-03-20 10:51:44\n*"
}
]
About this extraction
This page contains the full source code of the nowa-webpack/nowa GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 12 files (11.7 KB), approximately 3.5k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.