Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-noderize

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-noderize - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

src/run.js

67

dist/index.js

@@ -84,2 +84,20 @@ #!/usr/bin/env node

var _run = __webpack_require__(1);
var _minimist = _interopRequireDefault(__webpack_require__(8));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Parse args
const args = (0, _minimist.default)(process.argv.slice(2));
const name = args._.length > 0 ? args._[0] : null;
(0, _run.run)(name, args);
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {

@@ -90,16 +108,14 @@ value: true

var _ncp = __webpack_require__(1);
var _ncp = __webpack_require__(2);
var _chalk = _interopRequireDefault(__webpack_require__(2));
var _chalk = _interopRequireDefault(__webpack_require__(3));
var _util = __webpack_require__(3);
var _util = __webpack_require__(4);
var _path = __webpack_require__(4);
var _path = __webpack_require__(5);
var _fs = _interopRequireDefault(__webpack_require__(5));
var _fs = _interopRequireDefault(__webpack_require__(6));
var _child_process = __webpack_require__(6);
var _child_process = __webpack_require__(7);
var _minimist = _interopRequireDefault(__webpack_require__(7));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -111,3 +127,3 @@

function run(_x) {
function run() {
return _run.apply(this, arguments);

@@ -117,3 +133,3 @@ }

function _run() {
_run = _asyncToGenerator(function* (name, {
_run = _asyncToGenerator(function* (name = null, {
typescript = false,

@@ -126,2 +142,3 @@ forceNpm = false,

process.exit(1);
return;
} // Get absolute path

@@ -135,2 +152,3 @@

process.exit(1);
return;
}

@@ -145,2 +163,3 @@

process.exit(1);
return;
}

@@ -171,2 +190,3 @@

process.exit(1);
return;
} // Move "gitignore" to ".gitignore"

@@ -177,4 +197,6 @@

_fs.default.renameSync((0, _path.resolve)(path, "gitignore"), (0, _path.resolve)(path, ".gitignore"));
} catch (err) {
} catch (error) {
printError(`Error moving .gitignore.`, error);
process.exit(1);
return;
}

@@ -189,2 +211,3 @@

process.exit(1);
return;
}

@@ -213,2 +236,3 @@ }

process.exit(1);
return;
}

@@ -236,9 +260,4 @@

}
} // Parse args
}
const args = (0, _minimist.default)(process.argv.slice(2));
const name = args._.length > 0 ? args._[0] : null;
run(name, args);
function printInfo(text) {

@@ -262,3 +281,3 @@ console.log(`${_chalk.default.blueBright("[INFO]")} ${text}`);

/***/ }),
/* 1 */
/* 2 */
/***/ (function(module, exports) {

@@ -269,3 +288,3 @@

/***/ }),
/* 2 */
/* 3 */
/***/ (function(module, exports) {

@@ -276,3 +295,3 @@

/***/ }),
/* 3 */
/* 4 */
/***/ (function(module, exports) {

@@ -283,3 +302,3 @@

/***/ }),
/* 4 */
/* 5 */
/***/ (function(module, exports) {

@@ -290,3 +309,3 @@

/***/ }),
/* 5 */
/* 6 */
/***/ (function(module, exports) {

@@ -297,3 +316,3 @@

/***/ }),
/* 6 */
/* 7 */
/***/ (function(module, exports) {

@@ -304,3 +323,3 @@

/***/ }),
/* 7 */
/* 8 */
/***/ (function(module, exports) {

@@ -307,0 +326,0 @@

@@ -10,7 +10,7 @@ {

},
"version": "0.2.4",
"version": "0.2.5",
"license": "MIT",
"bin": "dist/index.js",
"devDependencies": {
"noderize-scripts": "^0.2.4"
"noderize-scripts": "^0.2.5"
},

@@ -17,0 +17,0 @@ "scripts": {

@@ -1,118 +0,4 @@

import { ncp } from "ncp";
import chalk from "chalk";
import { promisify } from "util";
import { resolve } from "path";
import fs from "fs";
import { execSync } from "child_process";
import { run } from "./run"
import parseArgs from "minimist";
export async function run(
name,
{ typescript = false, forceNpm = false, forceYarn = false } = {}
) {
if (!name) {
printWarn(`No path given!`);
process.exit(1);
}
// Get absolute path
const path = resolve(fs.realpathSync(process.cwd()), name);
// Check if exist
if (fs.existsSync(path)) {
printWarn(`Path exists!`);
process.exit(1);
}
printInfo(`Copying...`);
// Copy from template
try {
await promisify(ncp)(resolve(__dirname, "..", "template"), path);
} catch (error) {
error(`Error copying.`, error);
process.exit(1);
}
printInfo(`Setting up...`);
// Set the "name" field in package.json
try {
const childPackagePath = resolve(path, "package.json");
// Read
const childPackage = JSON.parse(fs.readFileSync(childPackagePath));
const newChildPackage = { name, ...childPackage }; // Hack to put name at front
if (typescript) {
newChildPackage.noderize = { languages: "typescript" };
}
// Write
fs.writeFileSync(
childPackagePath,
JSON.stringify(newChildPackage, null, "\t")
);
} catch (error) {
printError(`Error saving package.json.`, error);
process.exit(1);
}
// Move "gitignore" to ".gitignore"
try {
fs.renameSync(resolve(path, "gitignore"), resolve(path, ".gitignore"));
} catch (err) {
printError(`Error moving .gitignore.`, error);
}
if (typescript) {
// Setup TypeScript
try {
fs.renameSync(
resolve(path, "src", "index.js"),
resolve(path, "src", "index.ts")
);
} catch (error) {
printError(`Error moving src/index.js to src/index.ts.`, error);
process.exit(1);
}
}
printInfo(`Installing packages...`);
console.log();
const useYarn = forceYarn ? true : forceNpm ? false : shouldUseYarn();
try {
// Install latest
if (useYarn) {
execSync("yarn add -D noderize-scripts", { cwd: path, stdio: "inherit" });
} else {
execSync("npm install -D noderize-scripts", {
cwd: path,
stdio: "inherit"
});
}
} catch (error) {
printError(`Error installing packages.`, error);
process.exit(1);
}
const runCommand = useYarn ? "yarn" : "npm run";
console.log();
printDone(`Done! Your Noderize app is ready!`);
printDone(`You may visit your app with ${chalk.cyan(`cd ${name}`)}`);
printDone(`Develop by using ${chalk.cyan(`${runCommand} watch`)}`);
printDone(
`Build a production version using ${chalk.cyan(`${runCommand} build`)}`
);
printDone(`Visit documentation at ${chalk.cyan(`https://noderize.js.org`)}`);
}
function shouldUseYarn() {
try {
execSync("yarn --version", { stdio: "ignore" });
return true;
} catch (error) {
return false;
}
}
// Parse args

@@ -123,18 +9,1 @@ const args = parseArgs(process.argv.slice(2));

run(name, args);
function printInfo(text) {
console.log(`${chalk.blueBright("[INFO]")} ${text}`);
}
function printDone(text) {
console.log(`${chalk.greenBright("[DONE]")} ${text}`);
}
function printWarn(text) {
console.warn(`${chalk.yellowBright("[WARN]")} ${text}`);
}
function printError(text, error) {
console.error(`${chalk.redBright("[ERROR]")} ${text}`);
console.error(error);
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc