forked from EuCaue/gnome-shell-extension-quick-lofi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
70 lines (60 loc) · 2.23 KB
/
Copy pathbuild.js
File metadata and controls
70 lines (60 loc) · 2.23 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
import { execSync } from 'child_process';
import { cpSync, readFileSync, rmSync } from 'fs';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import AdmZip from 'adm-zip';
const __dirname = dirname(fileURLToPath(import.meta.url));
const metadata = JSON.parse(readFileSync('./src/metadata.json', 'utf-8'));
function prepareFiles() {
const filesToCopy = [
{
src: 'src/metadata.json',
dist: 'dist/metadata.json',
},
{
src: 'schemas',
dist: 'dist/schemas',
},
{
src: 'icons',
dist: 'dist/icons',
},
{
src: 'src/resources',
dist: 'dist/resources',
},
];
filesToCopy.forEach(({ src, dist }) => {
cpSync(resolve(__dirname, src), resolve(__dirname, dist), { recursive: true });
});
rmSync(resolve(__dirname, 'dist/resources/quick-lofi.gresource.xml'));
rmSync(resolve(__dirname, 'dist/schemas/gschemas.compiled'));
execSync(
'glib-compile-resources src/resources/quick-lofi.gresource.xml --target=dist/resources/quick-lofi.gresource --sourcedir=src/resources',
{
stdio: 'inherit',
},
);
}
function main() {
console.log(`Building ${metadata.name} v${metadata['shell-version']}...`);
execSync('npx rollup -c', { stdio: 'inherit' });
prepareFiles();
const zipFilename = `${metadata.uuid}.zip`;
const zipDist = resolve(__dirname, zipFilename);
const zip = new AdmZip();
zip.addLocalFolder(resolve(__dirname, 'dist'));
zip.writeZip(zipDist);
console.log(`Build complete. Zip file: ${zipFilename}\n`);
console.log(`Install with: gnome-extensions install ${zipFilename}`);
console.log(`Update with: gnome-extensions install --force ${zipFilename}`);
console.log(`Enable with: gnome-extensions enable ${metadata.uuid}`);
console.log('');
console.log(`Disable with: gnome-extensions disable ${metadata.uuid}`);
console.log(`Remove with: gnome-extensions uninstall ${metadata.uuid}`);
console.log('');
console.log('To check if the extension has been recognized, you can execute the following: gnome-extensions list.');
console.log(`If ${metadata.uuid} is listed in the output, you should be able to activate the extension.`);
console.log('Otherwise, you will need to restart the GNOME Shell.');
}
main();