Skip to content

Commit

Permalink
chore: init rapid.app with electron
Browse files Browse the repository at this point in the history
  • Loading branch information
tianding.wk committed Aug 11, 2023
1 parent 652e0ca commit 63f12d4
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 52 deletions.
64 changes: 13 additions & 51 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand All @@ -15,6 +14,7 @@ pids
*.pid
*.seed
*.pid.lock
.DS_Store

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
Expand All @@ -26,12 +26,6 @@ coverage
# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

Expand All @@ -42,8 +36,8 @@ build/Release
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo
Expand All @@ -54,15 +48,6 @@ web_modules/
# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

Expand All @@ -72,41 +57,22 @@ web_modules/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
# dotenv environment variables file
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
# next.js build output
.next
out

# Nuxt.js build / generate output
# nuxt.js build output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

Expand All @@ -116,15 +82,11 @@ dist
# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
# Webpack
.webpack/

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# Vite
.vite/

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# Electron-Forge
out/
5 changes: 5 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lockfile-version = 3
package-lock = false
NPM_CONFIG_ELECTRON_MIRROR = https://registry.npmmirror.com/binary.html?path=electron/
npm_config_electron_use_remote_checksums = true

2 changes: 2 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1. if you are encountering a forge precheck error, please run `touch ~/.skip-forge-system-check` to skip this check;
2. if you are encountering a electron checksum error when install deps, please run `electron_use_remote_checksums=true npm i`;
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# rapid.app
The desktop app for rapid npm installation.
The desktop app for [rapid](https://github.com/cnpm/rapid) npm installation.


# License
MIT
30 changes: 30 additions & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
packagerConfig: {
asar: true,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {},
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
],
};
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "rapid.app",
"productName": "rapid.app",
"version": "1.0.0",
"description": "The desktop app for rapid npm installation.",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
"@electron-forge/cli": "^6.3.0",
"@electron-forge/maker-deb": "^6.3.0",
"@electron-forge/maker-rpm": "^6.3.0",
"@electron-forge/maker-squirrel": "^6.3.0",
"@electron-forge/maker-zip": "^6.3.0",
"@electron-forge/plugin-auto-unpack-natives": "^6.3.0",
"electron": "^25.5.0"
},
"keywords": [
"rapid",
"desktop",
"cnpm",
"npm"
],
"author": {
"name": "gemwuu",
"email": "[email protected]"
},
"license": "MIT",
"repository": "[email protected]:cnpm/rapid.app.git"
}
7 changes: 7 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;
margin: auto;
max-width: 38rem;
padding: 2rem;
}
10 changes: 10 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>rapid.app!</title>
</head>
<body>
<h1>Hello rapid.app!</h1>
</body>
</html>
49 changes: 49 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}

const createWindow = () => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
},
});

// and load the index.html of the app.
mainWindow.loadFile(path.join(__dirname, 'index.html'));

// Open the DevTools.
mainWindow.webContents.openDevTools();
};

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);

// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
2 changes: 2 additions & 0 deletions src/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts

0 comments on commit 63f12d4

Please sign in to comment.