Skip to content

Commit 6e3e6ac

Browse files
jackkavdimitropoulosDMarby
authoredApr 20, 2022
remove packedDependencies and custom package script (Kong#4704)
Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com> Co-authored-by: David Marby <david@dmarby.se>
1 parent fec3e4d commit 6e3e6ac

22 files changed

+31378
-38242
lines changed
 

‎.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const {
1212
module.exports = {
1313
settings: {
1414
react: {
15-
version: '16.8', // note: remember to always keep this in sync with `"react": "^16.8.3",` which is present in any package.json of a project using React.
15+
version: '17.0.2', // note: remember to always keep this in sync with `"react": "^17.0.2",` which is present in any package.json of a project using React.
1616
},
1717
},
1818
parser: '@typescript-eslint/parser',

‎lerna.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"includeMergedTags": true,
44
"packages": [
55
"packages/*",
6-
"plugins/*",
7-
"packages/insomnia-app/build"
6+
"plugins/*"
87
],
98
"command": {
109
"version": {
1110
"exact": true,
1211
"forcePublish": true,
1312
"gitTagVersion": false,
14-
"push": false
13+
"push": false,
14+
"private": false
1515
},
1616
"publish": {
1717
"verifyAccess": false

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"watch:app": "npm run build:main.min.js --prefix packages/insomnia-app && npm run start:dev-server --prefix packages/insomnia-app",
2929
"app-start": "npm start --prefix packages/insomnia-app",
3030
"app-build": "npm run build --prefix packages/insomnia-app",
31-
"app-package": "npm run package --prefix packages/insomnia-app",
31+
"app-package": "npm run build --prefix packages/insomnia-app && npm run package --prefix packages/insomnia-app",
3232
"app-bump-version": "npm run bump-version --prefix packages/insomnia-app",
3333
"preinstall": "node ./scripts/check-version.js",
3434
"test:smoke:dev": "npm run test:dev --prefix packages/insomnia-smoke-test",

‎packages/insomnia-app/.babelrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ module.exports = {
1212
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
1313
['@babel/plugin-proposal-private-methods', { loose: true }]
1414
],
15-
1615
}

‎packages/insomnia-app/app/common/constants.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import path from 'path';
33
import { unreachableCase } from 'ts-assert-unreachable';
44

55
import appConfig from '../../config/config.json';
6+
import { version } from '../../package.json';
67
import { getDataDirectory, getPortableExecutableDir } from './electron-helpers';
78

89
const env = process['env'];
910

1011
// App Stuff
11-
export const getAppVersion = () => appConfig.version;
12+
export const getAppVersion = () => version;
1213
export const getProductName = () => appConfig.productName;
1314
export const getAppDefaultTheme = () => appConfig.theme;
1415
export const getAppDefaultLightTheme = () => appConfig.lightTheme;

‎packages/insomnia-app/app/common/electron-helpers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as electron from 'electron';
22
import mkdirp from 'mkdirp';
33
import { join } from 'path';
44

5-
import appConfig from '../../config/config.json';
5+
import { version } from '../../package.json';
66

77
export function clickLink(href: string) {
88
const { protocol } = new URL(href);
@@ -26,7 +26,7 @@ export function getDataDirectory() {
2626
export function getTempDir() {
2727
// NOTE: Using a fairly unique name here because "insomnia" is a common word
2828
const { app } = process.type === 'renderer' ? window : electron;
29-
const dir = join(app.getPath('temp'), `insomnia_${appConfig.version}`);
29+
const dir = join(app.getPath('temp'), `insomnia_${version}`);
3030
mkdirp.sync(dir);
3131
return dir;
3232
}

‎packages/insomnia-app/app/main.development.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ log.info(`Running version ${getAppVersion()}`);
3838
const envDataPath = process.env.INSOMNIA_DATA_PATH;
3939
if (envDataPath) {
4040
app.setPath('userData', envDataPath);
41-
} else if (!isDevelopment()) {
41+
} else {
4242
// Explicitly set userData folder from config because it's sketchy to rely on electron-builder to use productName, which could be changed by accident.
4343
const defaultPath = app.getPath('userData');
44-
const newPath = path.join(defaultPath, '../', appConfig.userDataFolder);
44+
const newPath = path.join(defaultPath, '../', isDevelopment() ? 'insomnia-app' : appConfig.userDataFolder);
4545
app.setPath('userData', newPath);
4646
}
4747

‎packages/insomnia-app/app/plugins/context/__tests__/app.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import electron from 'electron';
22
import { mocked } from 'ts-jest/utils';
33

4-
import appConfig from '../../../../config/config.json';
4+
import appPackageJson from '../../../../package.json';
55
import { globalBeforeEach } from '../../../__jest__/before-each';
66
import { RENDER_PURPOSE_SEND } from '../../../common/render';
77
import * as modals from '../../../ui/components/modals';
@@ -113,7 +113,7 @@ describe('app.getInfo()', () => {
113113
it('provides app info', async () => {
114114
const result = plugin.init();
115115
expect(result.app.getInfo()).toEqual({
116-
'version': appConfig.version,
116+
'version': appPackageJson.version,
117117
'platform': process.platform,
118118
});
119119
});

‎packages/insomnia-app/config/config.json

-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
2-
"version": "2022.3.0-beta.3",
32
"name": "insomnia",
4-
"executableName": "insomnia",
53
"appId": "com.insomnia.app",
64
"userDataFolder": "Insomnia",
75
"productName": "Insomnia",
8-
"binaryPrefix": "Insomnia.Core",
96
"synopsis": "The Collaborative API Client and Design Tool",
107
"icon": "https://github.com/kong/insomnia/blob/develop/packages/insomnia-app/app/icons/icon.ico?raw=true",
118
"changelogUrl": "https://insomnia.rest/changelog",

‎packages/insomnia-app/config/electronbuilder.json

-89
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
const BINARY_PREFIX = 'Insomnia.Core';
2+
3+
// NOTE: USE_HARD_LINKS
4+
// https://github.com/electron-userland/electron-builder/issues/4594#issuecomment-574653870
5+
6+
/**
7+
* @type {import('electron-builder').Configuration}
8+
* @see https://www.electron.build/configuration/configuration
9+
*/
10+
const config = {
11+
appId: 'com.insomnia.app',
12+
protocols: [
13+
{
14+
name: 'Insomnia',
15+
role: 'Viewer',
16+
schemes: ['insomnia'],
17+
},
18+
],
19+
files: [
20+
{
21+
from: './build',
22+
to: '.',
23+
filter: ['**/*', '!opensource-licenses.txt'],
24+
},
25+
'./package.json',
26+
],
27+
publish: null,
28+
afterSign: './scripts/afterSignHook.js',
29+
extraResources: [
30+
{
31+
from: './bin',
32+
to: './bin',
33+
filter: 'yarn-standalone.js',
34+
},
35+
{
36+
from: './build',
37+
to: '.',
38+
filter: 'opensource-licenses.txt',
39+
},
40+
],
41+
extraMetadata: {
42+
main: 'main.min.js', // Override the main path in package.json
43+
},
44+
fileAssociations: [],
45+
mac: {
46+
hardenedRuntime: true,
47+
category: 'public.app-category.developer-tools',
48+
entitlements: './build/static/entitlements.mac.inherit.plist',
49+
artifactName: `${BINARY_PREFIX}-\${version}.\${ext}`,
50+
target: [
51+
{
52+
target: 'dmg',
53+
arch: 'universal',
54+
},
55+
{
56+
target: 'zip',
57+
arch: 'universal',
58+
},
59+
],
60+
extendInfo: {
61+
NSRequiresAquaSystemAppearance: false,
62+
},
63+
},
64+
dmg: {
65+
window: {
66+
width: 540,
67+
height: 380,
68+
},
69+
contents: [
70+
{
71+
x: 130,
72+
y: 186,
73+
},
74+
{
75+
x: 409,
76+
y: 186,
77+
type: 'link',
78+
path: '/Applications',
79+
},
80+
],
81+
},
82+
win: {
83+
target: [
84+
{
85+
target: 'squirrel',
86+
},
87+
{
88+
target: 'portable',
89+
},
90+
],
91+
},
92+
squirrelWindows: {
93+
artifactName: `${BINARY_PREFIX}-\${version}.\${ext}`,
94+
iconUrl:
95+
'https://github.com/kong/insomnia/blob/develop/packages/insomnia-app/app/icons/icon.ico?raw=true',
96+
},
97+
portable: {
98+
artifactName: `${BINARY_PREFIX}-\${version}-portable.\${ext}`,
99+
},
100+
linux: {
101+
artifactName: `${BINARY_PREFIX}-\${version}.\${ext}`,
102+
executableName: 'insomnia',
103+
synopsis: 'The Collaborative API Client and Design Tool',
104+
category: 'Development',
105+
target: [
106+
{
107+
target: 'AppImage',
108+
},
109+
{
110+
target: 'deb',
111+
},
112+
{
113+
target: 'tar.gz',
114+
},
115+
{
116+
target: 'rpm',
117+
},
118+
{
119+
target: 'snap',
120+
},
121+
],
122+
},
123+
};
124+
125+
const { env: { BUILD_TARGETS }, platform } = process;
126+
const targets = BUILD_TARGETS?.split(',');
127+
if (platform && targets) {
128+
console.log('overriding build targets to: ', targets);
129+
const PLATFORM_MAP = { darwin: 'mac', linux: 'linux', win32: 'win' };
130+
config[PLATFORM_MAP[platform]].target = config[PLATFORM_MAP[platform]].target.filter(({ target }) => targets.includes(target));
131+
}
132+
module.exports = config;

‎packages/insomnia-app/esbuild.main.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@ interface Options {
1010

1111
export default async function build(options: Options) {
1212
const mode = options.mode || 'production';
13-
// The list of packages that will be included in the node_modules folder of the packaged app.
14-
// Exclude all package.json dependencies except from the ones in the packedDependencies list
15-
const unpackedDependencies = [
16-
...Object.keys(pkg.dependencies).filter(
17-
name => !pkg.packedDependencies.includes(name)
18-
),
19-
];
20-
2113
const __DEV__ = mode !== 'production';
2214
const PORT = pkg.dev['dev-server-port'];
2315

@@ -51,7 +43,7 @@ export default async function build(options: Options) {
5143
external: [
5244
'electron',
5345
'@getinsomnia/node-libcurl',
54-
...Object.keys(unpackedDependencies),
46+
...Object.keys(pkg.dependencies),
5547
...Object.keys(builtinModules),
5648
],
5749
});

0 commit comments

Comments
 (0)
Please sign in to comment.