Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default async ({
dir = process.cwd(),
interactive = false,
confirmImport,
shouldContinueOnExisting,
shouldRemoveDependency,
shouldUpdateScript,
outDir,
}: ImportOptions) => {
const calculatedOutDir = outDir || 'out';
asyncOra.interactive = interactive;
d(`Attempting to import project in: ${dir}`);
if (!await fs.pathExists(dir) || !await fs.pathExists(path.resolve(dir, 'package.json'))) {
throw new Error(`We couldn't find a project in: ${dir}`);
}
// eslint-disable-next-line max-len
if (typeof confirmImport === 'function') {
if (!await confirmImport()) {
process.exit(0);
}
}
await initGit(dir);
const importDeps = ([] as string[]).concat(deps);
export default async ({
dir = process.cwd(),
interactive = false,
copyCIFiles = false,
force = false,
template = 'base',
}: InitOptions) => {
asyncOra.interactive = interactive;
d(`Initializing in: ${dir}`);
await initDirectory(dir, force);
await initGit(dir);
const templateModule = await findTemplate(dir, template);
if (typeof templateModule.initializeTemplate === 'function') {
await templateModule.initializeTemplate(dir, { copyCIFiles });
const packageJSON = await readRawPackageJson(dir);
setInitialForgeConfig(packageJSON);
await fs.writeJson(path.join(dir, 'package.json'), packageJSON, { spaces: 2 });
}
await asyncOra('Installing Template Dependencies', async () => {
d('installing dependencies');
export default async ({
dir = process.cwd(),
appPath = '.',
interactive = false,
enableLogging = false,
args = [],
runAsNode = false,
inspect = false,
}: StartOptions) => {
asyncOra.interactive = interactive;
await asyncOra('Locating Application', async () => {
const resolvedDir = await resolveDir(dir);
if (!resolvedDir) {
throw new Error('Failed to locate startable Electron application');
}
dir = resolvedDir;
});
const forgeConfig = await getForgeConfig(dir);
const packageJSON = await readMutatedPackageJson(dir, forgeConfig);
if (!packageJSON.version) {
throw new Error(`Please set your application's 'version' in '${dir}/package.json'.`);
}
export default async ({
dir = process.cwd(),
interactive = false,
skipPackage = false,
arch = getHostArch() as ForgeArch,
platform = process.platform as ForgePlatform,
overrideTargets,
outDir,
}: MakeOptions) => {
asyncOra.interactive = interactive;
let forgeConfig!: ForgeConfig;
await asyncOra('Resolving Forge Config', async () => {
const resolvedDir = await resolveDir(dir);
if (!resolvedDir) {
throw new Error('Failed to locate makeable Electron application');
}
dir = resolvedDir;
forgeConfig = await getForgeConfig(dir);
});
const actualOutDir = outDir || getCurrentOutDir(dir, forgeConfig);
const actualTargetPlatform = platform;
platform = platform === 'mas' ? 'darwin' : platform;
export default async ({
interactive = false,
prerelease = false,
repo,
chooseAsset,
}: InstallOptions) => {
asyncOra.interactive = interactive;
if (typeof chooseAsset !== 'function') {
throw new Error('Expected chooseAsset to be a function in install call');
}
let latestRelease!: Release;
let possibleAssets: Asset[] = [];
await asyncOra('Searching for Application', async (searchSpinner) => {
if (!repo || !repo.includes('/')) {
throw new Error('Invalid repository name, must be in the format owner/name');
}
d('searching for repo:', repo);
let releases!: Release[];
try {
const publish = async ({
dir = process.cwd(),
interactive = false,
makeOptions = {},
publishTargets = undefined,
dryRun = false,
dryRunResume = false,
makeResults = undefined,
outDir,
}: PublishOptions) => {
asyncOra.interactive = interactive;
if (dryRun && dryRunResume) {
throw new Error("Can't dry run and resume a dry run at the same time");
}
if (dryRunResume && makeResults) {
throw new Error("Can't resume a dry run and use the provided makeResults at the same time");
}
const forgeConfig = await getForgeConfig(dir);
const calculatedOutDir = outDir || getCurrentOutDir(dir, forgeConfig);
const dryRunDir = path.resolve(calculatedOutDir, 'publish-dry-run');
if (dryRunResume) {
d('attempting to resume from dry run');
const publishes = await PublishState.loadFromDirectory(dryRunDir, dir);
export default async ({
dir = process.cwd(),
interactive = false,
}: LintOptions) => {
asyncOra.interactive = interactive;
let success = true;
let result = null;
await asyncOra('Linting Application', async (lintSpinner) => {
const resolvedDir = await resolveDir(dir);
if (!resolvedDir) {
throw new Error('Failed to locate lintable Electron application');
}
dir = resolvedDir;
d('executing "run lint" in dir:', dir);
try {
await yarnOrNpmSpawn(['run', 'lint'], {
stdio: process.platform === 'win32' ? 'inherit' : 'pipe',