Repository navigation
Expand file tree
/
Copy pathelectron-builder.js
More file actions
230 lines (221 loc) 路 6.2 KB
/
Copy pathelectron-builder.js
File metadata and controls
230 lines (221 loc) 路 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
const { getSupportedLocales } = require('./app/utilities/i18n')
const { getElectronLanguages } = require('./configs/electronLanguages')
function buildGithubPublishConfig () {
const releaseType = process.env.LEPTON_GITHUB_RELEASE_TYPE
return {
provider: 'github',
...(releaseType ? { releaseType } : {})
}
}
function buildSnapStorePublishConfig () {
const channels = process.env.LEPTON_SNAP_CHANNELS
? process.env.LEPTON_SNAP_CHANNELS.split(',').map(channel => channel.trim()).filter(Boolean)
: undefined
return {
provider: 'snapStore',
publishAutoUpdate: false,
...(channels && channels.length > 0 ? { channels } : {})
}
}
const githubPublishConfig = buildGithubPublishConfig()
const snapStorePublishConfig = buildSnapStorePublishConfig()
// Keep only app source that the Electron main process reads at runtime.
// Renderer source is compiled into bundle/app.bundle.js and does not need to
// ship separately inside app.asar.
const mainRuntimeAppFiles = [
'app/utilities/accessTokenStorage.js',
'app/utilities/auth/**',
'app/utilities/config/**',
'app/utilities/electronLocalStorage.js',
'app/utilities/electronProxy/**',
'app/utilities/githubApi/core.js',
'app/utilities/githubApi/fetchAdapter.js',
'app/utilities/i18n/**',
'app/utilities/jupyterNotebook/core.js',
'app/utilities/logging/**',
'app/utilities/menu/**',
'app/utilities/startAtLogin/**',
'app/utilities/updatePolicy.js',
'app/utilities/zoom/**'
]
// Packages in this list are renderer-only dependencies that webpack already
// folds into bundle/app.bundle.js. Excluding their node_modules copies trims the
// packaged archive without changing runtime module resolution.
const rendererOnlyNodeModules = [
'@asciidoctor/core',
'@babel/runtime',
'@babel/runtime-corejs2',
'@kurkle/color',
'@mdit/helper',
'@mdit/plugin-katex',
'@mdit/plugin-tex',
'asciidoctor-opal-runtime',
'autolinker',
'boring-avatars',
'chart.js',
'classnames',
'codemirror',
'codemirror-one-dark-theme',
'core-js',
'dom-helpers',
'highlight.js',
'highlightjs-graphql',
'highlightjs-solidity',
'human-readable-time',
'katex',
'keycode',
'linkify-it',
'loose-envify',
'markdown-it',
'markdown-it-emoji',
'markdown-it-task-lists',
'mdurl',
'moment',
'object-assign',
'invariant',
'js-tokens',
'punycode.js',
'prop-types',
'prop-types-extra',
'react',
'react-bootstrap',
'react-dom',
'react-is',
'react-lifecycles-compat',
'react-overlays',
'react-prop-types',
'react-redux',
'react-split-pane',
'react-transition-group',
'redux',
'redux-thunk',
'scheduler',
'tslib',
'uc.micro',
'uncontrollable',
'use-sync-external-store',
'valid-filename',
'warning'
]
// Some packages are renderer-only at the root, but package-manager hoisting can
// also place versions of the same package under runtime dependencies. Exclude
// only the root copy when nested copies may still be needed by main-process IPC.
const topLevelRendererOnlyNodeModules = [
'entities'
]
// Apply package exclusions to both direct dependencies and nested copies so
// transitive renderer-only packages do not remain in the final archive.
function excludeNodeModule (packageName) {
return [
`!node_modules/${packageName}/**`,
`!node_modules/**/node_modules/${packageName}/**`
]
}
module.exports = {
// electron-builder processes this list in order. The allowlist keeps the app
// payload intentionally small, and later negated patterns remove build-only
// or renderer-only artifacts that can otherwise be pulled in through deps.
files: [
...mainRuntimeAppFiles,
'bundle/**',
'configs/**',
'build/icon/icon.png',
'build/icon/tray-flowerTemplate.png',
'build/icon/tray-flowerTemplate@2x.png',
'build/touchbar/**',
'index.html',
'main.js',
'preload.js',
'package.json',
'license.json',
'.all-contributorsrc',
'!**/*.map',
'!node_modules/@types/**',
'!node_modules/**/node_modules/@types/**',
...rendererOnlyNodeModules.flatMap(excludeNodeModule),
...topLevelRendererOnlyNodeModules.map(packageName => `!node_modules/${packageName}/**`)
],
appId: 'com.cosmox.lepton',
// electron-builder expands these macros at packaging time.
// eslint-disable-next-line no-template-curly-in-string
artifactName: '${productName}-${version}-${os}-${arch}.${ext}',
// Keep Electron's own locale files aligned with the locales Lepton exposes in
// the renderer. Add new locales in the shared i18n config first, then let this
// derived list control the packaged Electron resources.
electronLanguages: getElectronLanguages(getSupportedLocales()),
// macOS builds use ad-hoc signing so Gatekeeper sees a structurally valid
// bundle without requiring a paid Apple Developer account. This still does
// not provide Developer ID trust or notarization.
mac: {
category: 'public.app-category.productivity',
identity: '-',
hardenedRuntime: false,
target: [
{
target: 'dmg',
arch: [
'x64',
'arm64'
]
},
{
target: 'zip',
arch: [
'x64',
'arm64'
]
}
],
publish: [
githubPublishConfig
],
darkModeSupport: true
},
// Windows builds keep the configurable installer and an archive artifact for
// the supported desktop architectures.
win: {
target: [
{
target: 'nsis',
arch: [
'x64',
'ia32'
]
},
{
target: '7z',
arch: [
'x64',
'ia32'
]
}
],
publish: [
githubPublishConfig
]
},
// NSIS settings preserve the current installer UX: guided install flow with a
// selectable installation directory.
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true
},
// Linux targets stay as strings because this electron-builder version validates
// Linux target entries as scalar target names. Snap Store publishing belongs in
// the dedicated snap config below.
linux: {
category: 'Development',
target: [
'AppImage',
'snap'
],
publish: [
githubPublishConfig
]
},
snap: {
publish: [
snapStorePublishConfig
]
}
}