@blitzjs/cli
Advanced tools
Comparing version 0.11.0 to 0.12.0-canary.3
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const repl_1 = require("@blitzjs/repl"); | ||
const command_1 = require("@oclif/command"); | ||
const REPL = tslib_1.__importStar(require("repl")); | ||
const path_1 = tslib_1.__importDefault(require("path")); | ||
const fs_1 = tslib_1.__importDefault(require("fs")); | ||
const chokidar_1 = require("chokidar"); | ||
const pkg_dir_1 = tslib_1.__importDefault(require("pkg-dir")); | ||
const server_1 = require("@blitzjs/server"); | ||
const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
const os_1 = tslib_1.__importDefault(require("os")); | ||
// import {loadDependencies} from '../utils/load-dependencies' | ||
const load_blitz_1 = require("../utils/load-blitz"); | ||
const setup_ts_node_1 = require("../utils/setup-ts-node"); | ||
const db_1 = require("./db"); | ||
@@ -28,65 +25,9 @@ const projectRoot = pkg_dir_1.default.sync() || process.cwd(); | ||
if (isTypescript) { | ||
load_blitz_1.setupTsnode(); | ||
setup_ts_node_1.setupTsnode(); | ||
} | ||
yield db_1.runPrismaGeneration({ silent: true }); | ||
spinner.succeed(); | ||
const repl = Console.initializeRepl(); | ||
const watchers = [ | ||
// watch('package.json').on('change', () => Console.loadDependencies(repl)), | ||
chokidar_1.watch(load_blitz_1.getBlitzModulePaths()).on('all', () => Console.loadBlitz(repl)), | ||
]; | ||
repl | ||
.on('reset', () => Console.loadModules(repl)) | ||
.on('exit', () => watchers.forEach((watcher) => watcher.close())); | ||
repl_1.runRepl(Console.replOptions); | ||
}); | ||
} | ||
static setupSelfRolledHistory(repl, path) { | ||
function init() { | ||
try { | ||
const history = fs_1.default.readFileSync(path, { encoding: 'utf8' }); | ||
const nonEmptyLines = history.split(os_1.default.EOL).filter((line) => line.trim()); | ||
repl.history.push(...nonEmptyLines.reverse()); | ||
} | ||
catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw err; | ||
} | ||
} | ||
} | ||
function onExit() { | ||
const addedHistory = repl.lines.join(os_1.default.EOL); | ||
fs_1.default.appendFileSync(path, addedHistory); | ||
} | ||
init(); | ||
repl.on('exit', onExit); | ||
} | ||
static setupHistory(repl) { | ||
const blitzConsoleHistoryPath = path_1.default.join(projectRoot, '.blitz-console-history'); | ||
if (repl.setupHistory) { | ||
repl.setupHistory(blitzConsoleHistoryPath, () => { }); | ||
} | ||
else { | ||
this.setupSelfRolledHistory(repl, blitzConsoleHistoryPath); | ||
} | ||
} | ||
static initializeRepl() { | ||
const repl = REPL.start(Console.replOptions); | ||
Console.defineCommands(repl, Console.commands); | ||
Console.loadModules(repl); | ||
this.setupHistory(repl); | ||
return repl; | ||
} | ||
static loadModules(repl) { | ||
// Console.loadDependencies(repl) | ||
Console.loadBlitz(repl); | ||
} | ||
// private static loadDependencies(repl: REPLServer) { | ||
// Object.assign(repl.context, loadDependencies(process.cwd())) | ||
// } | ||
static loadBlitz(repl) { | ||
Object.assign(repl.context, load_blitz_1.loadBlitz()); | ||
} | ||
static defineCommands(repl, commands) { | ||
Object.entries(commands).forEach(([keyword, cmd]) => repl.defineCommand(keyword, cmd)); | ||
} | ||
} | ||
@@ -100,12 +41,1 @@ exports.Console = Console; | ||
}; | ||
Console.commands = { | ||
reload: { | ||
help: 'Reload all modules', | ||
action() { | ||
this.clearBufferedCommand(); | ||
console.log('Reloading all modules...'); | ||
Console.loadModules(this); | ||
this.displayPrompt(); | ||
}, | ||
}, | ||
}; |
@@ -208,5 +208,7 @@ "use strict"; | ||
else { | ||
this.log("\nUh oh, we don't support that command."); | ||
this.log('\nUh oh, Blitz does not support that command.'); | ||
this.log('You can try running a prisma command directly with:'); | ||
this.log('\n `npm run prisma COMMAND` or `yarn prisma COMMAND`\n'); | ||
this.log('Or you can list available db commands with with:'); | ||
this.log('\n `npm run blitz db --help` or `yarn blitz db --help`\n'); | ||
} | ||
@@ -213,0 +215,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const command_1 = require("@oclif/command"); | ||
// Load the .env environment variable so it's avaiable for all commands | ||
// Load the .env environment variable so it's available for all commands | ||
require('dotenv').config(); | ||
@@ -6,0 +6,0 @@ function run() { |
{ | ||
"name": "@blitzjs/cli", | ||
"description": "Blitz.js CLI", | ||
"version": "0.11.0", | ||
"version": "0.12.0-canary.3", | ||
"license": "MIT", | ||
@@ -9,3 +9,7 @@ "scripts": { | ||
"clean": "rimraf lib", | ||
"predev": "wait-on ../installer/dist/packages/installer/src/index.d.ts && wait-on ../server/dist/packages/server/src/index.d.ts && wait-on ../generator/dist/packages/generator/src/index.d.ts", | ||
"predev": "yarn wait:installer && yarn wait:server && yarn wait:generator && yarn wait:repl", | ||
"wait:generator": "wait-on ../generator/dist/packages/generator/src/index.d.ts", | ||
"wait:server": "wait-on ../server/dist/packages/server/src/index.d.ts", | ||
"wait:installer": "wait-on ../installer/dist/packages/installer/src/index.d.ts", | ||
"wait:repl": "wait-on ../repl/dist/packages/repl/src/index.d.ts", | ||
"dev": "rimraf lib && tsc --watch --preserveWatchOutput", | ||
@@ -31,2 +35,3 @@ "build": "rimraf lib && tsc", | ||
"dependencies": { | ||
"@blitzjs/repl": "0.12.0-canary.3", | ||
"@oclif/command": "1.5.20", | ||
@@ -38,7 +43,5 @@ "@oclif/config": "1.15.1", | ||
"chalk": "4.0.0", | ||
"chokidar": "3.3.1", | ||
"cross-spawn": "7.0.2", | ||
"dotenv": "8.2.0", | ||
"enquirer": "2.3.4", | ||
"globby": "11.0.0", | ||
"got": "11.1.3", | ||
@@ -56,5 +59,5 @@ "has-yarn": "2.1.0", | ||
"devDependencies": { | ||
"@blitzjs/generator": "0.11.0", | ||
"@blitzjs/installer": "0.11.0", | ||
"@blitzjs/server": "0.11.0", | ||
"@blitzjs/generator": "0.12.0-canary.3", | ||
"@blitzjs/installer": "0.12.0-canary.3", | ||
"@blitzjs/server": "0.12.0-canary.3", | ||
"@oclif/dev-cli": "1.22.2", | ||
@@ -89,3 +92,3 @@ "@oclif/test": "1.2.5", | ||
}, | ||
"gitHead": "2c5bc8dbf42442968c5629783211fa84a3ab302b" | ||
"gitHead": "e1b1fcb6b5c27670624e23b1b70a183e15947083" | ||
} |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
20
7
45061
21
1003
+ Added@blitzjs/repl@0.12.0-canary.3(transitive)
- Removedchokidar@3.3.1
- Removedglobby@11.0.0