Skip to content

Commit

Permalink
feat: move create-electron-app into forge
Browse files Browse the repository at this point in the history
  • Loading branch information
VerteDinde committed Oct 25, 2022
1 parent 36dcdd0 commit a1d1459
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 49 deletions.
15 changes: 15 additions & 0 deletions packages/externals/create-electron-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "create-electron-app",
"version": "1.0.0",
"description": "Create Electron App",
"main": "src/index.js",
"typings": "../../api/cli/src/electron-forge-init.ts",
"author": "Samuel Attard",
"license": "MIT",
"dependencies": {
"@electron-forge/cli": "latest"
},
"bin": {
"create-electron-app": "./src/index"
}
}
3 changes: 3 additions & 0 deletions packages/externals/create-electron-app/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('@electron-forge/cli/dist/electron-forge-init.js');
3 changes: 3 additions & 0 deletions packages/externals/create-electron-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ts-node

require('@electron-forge/cli/dist/electron-forge-init.js');
74 changes: 37 additions & 37 deletions tools/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,46 +51,46 @@ const publisher = new Listr([
}
},
},
{
title: 'Publishing all packages',
task: async (ctx) => {
return new Listr(
await Promise.all(
ctx.dirsToPublish.map(async (dir) => {
const { name, version } = await fs.readJson(path.resolve(dir, 'package.json'));
// TODO: Re-enable this once V6 stable is released
// const isBeta = version.includes('beta');
const isBeta = false;
return {
title: `Publishing: ${chalk.cyan(`${name}@${version}`)} (beta=${isBeta ? chalk.green('true') : chalk.red('false')})`,
task: async () => {
try {
await spawn('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], {
cwd: dir,
});
} catch (err) {
throw new Error(`Failed to publish ${chalk.cyan(`${name}@${version}`)} \n${err.stderr.toString()}`);
}
},
};
})
),
{ concurrent: 5, exitOnError: false }
);
},
},
// {
// title: 'Publishing all packages',
// task: async (ctx) => {
// return new Listr(
// await Promise.all(
// ctx.dirsToPublish.map(async (dir) => {
// const { name, version } = await fs.readJson(path.resolve(dir, 'package.json'));
// // TODO: Re-enable this once V6 stable is released
// // const isBeta = version.includes('beta');
// const isBeta = false;
// return {
// title: `Publishing: ${chalk.cyan(`${name}@${version}`)} (beta=${isBeta ? chalk.green('true') : chalk.red('false')})`,
// task: async () => {
// try {
// await spawn('npm', ['publish', '--access=public', ...(isBeta ? ['--tag=beta'] : []), `--otp=${ctx.otp}`], {
// cwd: dir,
// });
// } catch (err) {
// throw new Error(`Failed to publish ${chalk.cyan(`${name}@${version}`)} \n${err.stderr.toString()}`);
// }
// },
// };
// })
// ),
// { concurrent: 5, exitOnError: false }
// );
// },
// },
]);

const runPublisher = async () => {
const otp = await new Promise((resolve) => {
process.stdin.once('data', (chunk) => {
process.stdin.pause();
resolve(chunk.toString());
});
process.stdout.write('Enter OTP: ');
process.stdin.read();
});
publisher.run({ otp });
// const otp = await new Promise((resolve) => {
// process.stdin.once('data', (chunk) => {
// process.stdin.pause();
// resolve(chunk.toString());
// });
// process.stdout.write('Enter OTP: ');
// process.stdin.read();
// });
// publisher.run({ otp });
};

prepare
Expand Down
28 changes: 16 additions & 12 deletions tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export const getPackageInfo = async (): Promise<Package[]> => {
for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir);
const pkg = await fs.readJson(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
if (fs.lstatSync(packagePath).isDirectory() ) {
const pkg = await fs.readJson(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
}
}
}

Expand All @@ -34,12 +36,14 @@ export const getPackageInfoSync = (): Package[] => {
for (const subDir of fs.readdirSync(PACKAGES_DIR)) {
for (const packageDir of fs.readdirSync(path.resolve(PACKAGES_DIR, subDir))) {
const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir);
const pkg = fs.readJsonSync(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
if (fs.lstatSync(packagePath).isDirectory() ) {
const pkg = fs.readJsonSync(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
}
}
}

Expand Down

0 comments on commit a1d1459

Please sign in to comment.