forked from windycom/windy-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepublish.js
45 lines (35 loc) · 1.33 KB
/
prepublish.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
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import assert from 'node:assert';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const { name, author, repository, description } = JSON.parse(
fs.readFileSync(path.join(__dirname, '..', 'package.json')),
);
assert(
name !== 'windy-plugin-example',
'Please modify name in your package.json, it is still default name \u0007',
);
assert(
/windy-plugin-\S+/.test(name),
'Name of your plugin MUST have form windy-plugin-XXXX. Please modify name in your package.json. \u0007',
);
assert(
!/default desc/.test(description),
'Please modify description in your package.json, it is still default description \u0007',
);
assert(
author !== 'Windyty, S.E.',
'Please modify author in your package.json, it is still default author \u0007',
);
assert(
repository && !/windycom/.test(repository.url),
'Please modify repository in your package.json, it is still default repository \u0007',
);
const readme = fs.readFileSync(path.join(__dirname, '..', 'README.md'), 'utf8');
assert(readme, 'README.md file missing\u0007');
assert(
!/This is default readme/.test(readme),
'The README.md file is still default, please delete it and put there info about your plugin \u0007',
);