forked from maidsafe/sn_browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-pack.js
128 lines (106 loc) · 3.4 KB
/
post-pack.js
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
#!/usr/bin/env node
const path = require( 'path' );
const fs = require( 'fs-extra' );
const RELEASE_FOLDER_NAME = require( './releaseName' );
const pkg = require( './package.json' );
const env = process.env.NODE_ENV || 'production';
const isBuildingDev = /^dev/.test( env );
const targetDir = path.resolve( __dirname, 'release' );
const { platform } = process;
const OSX = 'darwin';
const LINUX = 'linux';
const WINDOWS = 'win32';
// let PLATFORM_NAME;
let CONTAINING_FOLDER;
const LOGS = 'log.toml';
if ( platform === OSX ) {
CONTAINING_FOLDER = path.resolve( targetDir, 'mac' );
const PERUSE_FOLDER = path.resolve( CONTAINING_FOLDER, 'SAFE Browser.app' );
const PERUSE_CONTENTS_FOLDER = path.resolve( PERUSE_FOLDER, 'Contents' );
const PERUSE_RESOURCES_FOLDER = path.resolve(
PERUSE_CONTENTS_FOLDER,
'Resources'
);
const PERUSE_CONFIG_FOLDER = path.resolve(
PERUSE_FOLDER,
'Contents/Frameworks/SAFE Browser Helper.app/Contents/MacOS'
);
fs.moveSync(
path.resolve( PERUSE_RESOURCES_FOLDER, 'SAFE Browser.crust.config' ),
path.resolve( PERUSE_CONFIG_FOLDER, 'SAFE Browser Helper.crust.config' ),
{ overwrite: true }
);
fs.moveSync(
path.resolve( PERUSE_RESOURCES_FOLDER, LOGS ),
path.resolve( PERUSE_CONFIG_FOLDER, LOGS ),
{ overwrite: true }
);
// PLATFORM_NAME = 'osx';
if ( isBuildingDev ) {
fs.writeFileSync(
path.resolve( PERUSE_RESOURCES_FOLDER, 'startAsMock' ),
'unimportantContents'
);
}
}
if ( platform === LINUX ) {
CONTAINING_FOLDER = path.resolve( targetDir, 'linux-unpacked' );
// PLATFORM_NAME = LINUX;
const PERUSE_RESOURCES_FOLDER = path.resolve(
CONTAINING_FOLDER,
'resources'
);
fs.moveSync(
path.resolve( PERUSE_RESOURCES_FOLDER, 'SAFE Browser.crust.config' ),
path.resolve( CONTAINING_FOLDER, 'safe-browser.crust.config' ),
{ overwrite: true }
);
fs.moveSync(
path.resolve( PERUSE_RESOURCES_FOLDER, LOGS ),
path.resolve( CONTAINING_FOLDER, LOGS ),
{ overwrite: true }
);
}
if ( platform === WINDOWS ) {
CONTAINING_FOLDER = path.resolve( targetDir, 'win-unpacked' );
const PERUSE_RESOURCES_FOLDER = path.resolve(
CONTAINING_FOLDER,
'resources'
);
fs.copySync(
path.resolve( PERUSE_RESOURCES_FOLDER, 'SAFE Browser.crust.config' ),
path.resolve( CONTAINING_FOLDER, 'SAFE Browser.crust.config' ),
{ overwrite: true }
);
fs.unlinkSync(
path.resolve( PERUSE_RESOURCES_FOLDER, 'SAFE Browser.crust.config' )
);
// PLATFORM_NAME = 'win';
}
if ( isBuildingDev && ( platform === WINDOWS || platform === LINUX ) ) {
fs.writeFileSync(
path.resolve( CONTAINING_FOLDER, 'resources', 'startAsMock' ),
'unimportantContents'
);
}
// add version file
fs.outputFileSync( path.resolve( CONTAINING_FOLDER, 'version' ), pkg.version );
// remove licenses
const removalArray = [
'LICENSE.electron.txt',
'LICENSES.chromium.html',
'LICENSE'
];
removalArray.forEach( file => {
fs.removeSync( `${CONTAINING_FOLDER}/${file}` );
} );
console.info(
'Renaming package to:',
path.resolve( targetDir, `${RELEASE_FOLDER_NAME}` )
);
// rename release folder
fs.moveSync(
CONTAINING_FOLDER,
path.resolve( targetDir, `${RELEASE_FOLDER_NAME}` ),
{ overwrite: true }
);