Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// docsPath is required
if (!docsPath) usage('specify a pathname, .e.g ~/my/electron/electron')
// docsPath is relative to current working directory
docsPath = path.join(process.cwd(), docsPath)
// outfile is relative to current working directory
if (outfile) outfile = path.join(process.cwd(), outfile)
// version is required if writing to a file
if (outfile && !version) usage('`version` is required if `outfile` is specified')
// Use a placeholder version if not writing to a file
if (!version) version = '0.0.0'
const spinner = require('ora')('Parsing electron documentation').start()
lint(docsPath, version).then(function (apis) {
spinner.stop().clear()
apis.forEach(api => console.error(api.report()))
if (apis.some(api => !api.valid)) process.exit(1)
if (outfile) {
fs.writeFileSync(outfile, JSON.stringify(apis, null, 2))
console.log(dedent`
Created ${path.relative(process.cwd(), outfile)}
`)
} else {
console.log(dedent`
Docs are good to go!\n
import { dirname } from 'path';
import yParser from 'yargs-parser';
import signale from 'signale';
import semver from 'semver';
import ora from 'ora';
import buildDevOpts from './buildDevOpts';
const spinner = ora();
const script = process.argv[2];
const args = yParser(process.argv.slice(3));
// Node version check
const nodeVersion = process.versions.node;
if (semver.satisfies(nodeVersion, '<6.5')) {
signale.error(`Node version must >= 6.5, but got ${nodeVersion}`);
process.exit(1);
}
spinner.start('🏃 parsing parameters');
// Notify update when process exits
const updater = require('update-notifier');
const pkg = require('../package.json');
updater({ pkg }).notify({ defer: true });
(async function() {
// Intro logging
console.log(`\n${figlet.textSync('CASTER')}\n`);
try {
// Collect user configuration
const config = sanitizeInput(await collectInput());
console.log('');
// Generate project structure
const generation = generateStructure(config);
ora.promise(generation, { text: 'Generating project structure' });
await generation;
// Install project dependencies
const installation = execute('npm install', config.name);
ora.promise(installation, { text: 'Installing project dependencies' });
await installation;
// Success outro logging
console.log(
`\n ${chalk.bold(chalk.green('Success!'))} Generated ${config.name} at ${path.resolve(config.name)}.`
);
console.log(' The following commands are available within that directory:\n');
config.tech.js && console.log(` ${chalk.cyan('npm run test')} Runs JavaScript unit tests`);
config.tech.js && console.log(` ${chalk.cyan('npm run eslint')} Lints JavaScript files`);
config.tech.css && console.log(` ${chalk.cyan('npm run stylelint')} Lints CSS files`);
console.log(` ${chalk.cyan('npm run prettier')} Format files`);
static async spinPromise(promise, text, spinner, stream = process.stdout) {
ora.promise(promise, {
text: text,
spinner: spinner,
stream: stream
// color: false,
// enabled: true
});
return promise;
}
}
exports.handler = (args) => __awaiter(this, void 0, void 0, function* () {
let exit = 0;
const designFile = `${process.env.PWD}/${args.file}`;
const tmpDir = `${process.env.PWD}/tmp-${uuid_1.v4()}`; // TODO: use 'mkdtempSync'?
const authenticationDir = `${process.env.PWD}/src/authentication`;
const authorizationDir = `${process.env.PWD}/src/authorization`;
const contextDir = `${process.env.PWD}/src/context`;
const handlersDir = `${process.env.PWD}/src/handlers`;
const internalDir = `${process.env.PWD}/src/internal`;
const middlewareDir = `${process.env.PWD}/src/middleware`;
const spinner = ora_1.default('Generating api...').start();
try {
// 1. check if design file exists
if (yield !fs_extra_1.existsSync(designFile)) {
throw new Error(`could not open ${designFile}. File does not exists`);
}
// 2. load design file into object
const design = Object.assign(new design_1.default(), JSON.parse(yield fs_extra_1.readFileSync(designFile).toString()));
const errors = design.Validate();
if (errors && errors.length > 0) {
throw errors.map((error) => `${error}\n`);
}
// 3. generate the temporary 'internal' files
yield internal_1.genInternal(tmpDir, design);
// 4. remove the existing internal route files and copy over the new ones
if (yield !fs_extra_1.existsSync(internalDir)) {
throw new Error("could not find directory './internal'. Did you '$ design-first init [name] && cd [name] && design-first gen '?");
// @ts-check
const ora = require('ora').default
module.exports = ora()
import * as fs from 'fs-extra';
import * as path from 'path';
import * as os from 'os';
import * as ora from 'ora';
import { spawnPromise } from 'spawn-rx';
import { expect } from 'chai';
import { rebuild } from '../src/rebuild';
ora.ora = ora;
describe('rebuilder', () => {
const testModulePath = path.resolve(os.tmpdir(), 'electron-forge-rebuild-test');
const resetTestModule = async () => {
await fs.remove(testModulePath);
await fs.mkdirs(testModulePath);
await fs.writeFile(path.resolve(testModulePath, 'package.json'), await fs.readFile(path.resolve(__dirname, '../test/fixture/native-app1/package.json'), 'utf8'));
await spawnPromise('npm', ['install'], {
cwd: testModulePath,
stdio: 'ignore',
});
};
describe('core behavior', function() {
this.timeout(2 * 60 * 1000);
choices
}
]);
port = project === choices[0] ? 8081 : 19001;
}
if (!expoRunning && !rnRunning) {
console.log('None found.');
console.log(
`Could not find a React Native or Expo project running on port ${8081} or ${19001}. Start one and run 'npx visualize-bundle' again.`
);
console.log('');
process.exit(0);
}
const startTime = Date.now();
const spinner = ora();
spinner.start();
spinner.text = `Getting bundle from port ${port}...`;
await new Promise(resolve => setTimeout(resolve, 100));
try {
const bundle = await getAnyResource(
port === 19001
? [`http://localhost:19001/node_modules/expo/AppEntry.bundle?${query}`]
: [
`http://localhost:${port}/index.bundle?${query}`,
`http://localhost:${port}/index.${platform}.bundle?${query}`
]
);
spinner.text = `Getting map from port ${port}...`;
await new Promise(resolve => setTimeout(resolve, 100));
const sourceMap = await getAnyResource(
port === 19001
import { readFileSync, existsSync, unlinkSync } from "fs";
import { exec } from "child_process";
import rmdir from "rimraf";
import ncp from "ncp";
import tar from "tar";
import request from "request";
import ora from "ora";
if (!existsSync(".ret.credentials")) {
console.log("Not logged in, so cannot deploy. To log in, run npm run login.");
process.exit(0);
}
const { host, token } = JSON.parse(readFileSync(".ret.credentials"));
console.log(`Deploying to ${host}.`);
const step = ora({ indent: 2 }).start();
const getTs = (() => {
const p = n => (n < 10 ? `0${n}` : n);
return () => {
const d = new Date();
return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}${p(d.getHours())}${p(d.getMinutes())}${p(
d.getSeconds()
)}`;
};
})();
(async () => {
const headers = {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json"
};
emitter.on("create", (message, action) => {
if (action) ora.promise(action, message);
else console.log(message);
});