@prosopo/scripts 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
import { at } from '@prosopo/util';
|
|
2
|
+
import { getRootDir } from '@prosopo/config';
|
|
2
3
|
import { glob } from 'glob';
|
|
3
4
|
import fs from 'fs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const header = `// Copyright 2021-2024 Prosopo (UK) Ltd.
|
|
6
|
+
//
|
|
7
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
// you may not use this file except in compliance with the License.
|
|
9
|
+
// You may obtain a copy of the License at
|
|
10
|
+
//
|
|
11
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
//
|
|
13
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
// See the License for the specific language governing permissions and
|
|
17
|
+
// limitations under the License.`;
|
|
18
|
+
const searchPaths = [
|
|
19
|
+
'**/*.ts',
|
|
20
|
+
'**/*.tsx',
|
|
21
|
+
'**/*.rs',
|
|
22
|
+
'**/*.js',
|
|
23
|
+
'**/*.jsx',
|
|
24
|
+
'**/*.cjs',
|
|
25
|
+
'**/*.mjs',
|
|
26
|
+
'**/*.cts',
|
|
27
|
+
'**/*.mts',
|
|
28
|
+
];
|
|
29
|
+
const currentPath = getRootDir();
|
|
30
|
+
const files = glob
|
|
31
|
+
.sync(searchPaths, {
|
|
12
32
|
cwd: currentPath,
|
|
13
33
|
absolute: true,
|
|
14
34
|
ignore: [
|
|
@@ -19,58 +39,55 @@ const files = glob.sync(searchPaths, {
|
|
|
19
39
|
'**/coverage/**',
|
|
20
40
|
'**/vite.cjs.config.ts.timestamp*',
|
|
21
41
|
],
|
|
22
|
-
})
|
|
42
|
+
})
|
|
43
|
+
.filter((file) => fs.lstatSync(file).isFile());
|
|
23
44
|
if (process.argv[2] === 'list') {
|
|
24
45
|
console.log(JSON.stringify(files, null, 4));
|
|
25
46
|
console.log('Found', files.length, 'files');
|
|
26
47
|
}
|
|
48
|
+
if (process.argv[2] === 'check') {
|
|
49
|
+
for (const file of files) {
|
|
50
|
+
const fileContents = fs.readFileSync(file, 'utf8');
|
|
51
|
+
if (fileContents.startsWith(header)) {
|
|
52
|
+
console.log('License present:', file);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error(`License not present: ${file}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
27
59
|
if (process.argv[2] === 'license') {
|
|
28
|
-
const header = `// Copyright 2021-2024 Prosopo (UK) Ltd.
|
|
29
|
-
//
|
|
30
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
31
|
-
// you may not use this file except in compliance with the License.
|
|
32
|
-
// You may obtain a copy of the License at
|
|
33
|
-
//
|
|
34
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
-
//
|
|
36
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
37
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
-
// See the License for the specific language governing permissions and
|
|
40
|
-
// limitations under the License.`;
|
|
41
60
|
for (const file of files) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
line = at(lines, ++count);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (!line.startsWith('//')) {
|
|
56
|
-
count = count - 1;
|
|
57
|
-
line = at(lines, count);
|
|
58
|
-
}
|
|
59
|
-
if (line.endsWith('If not, see <http://www.gnu.org/licenses/>.') ||
|
|
60
|
-
line.endsWith('// limitations under the License.')) {
|
|
61
|
-
const newFileContents = `${header}\n${lines.slice(count + 1).join('\n')}`;
|
|
62
|
-
if (newFileContents !== fileContents) {
|
|
63
|
-
fs.writeFileSync(file, newFileContents);
|
|
64
|
-
console.log('File Updated:', file);
|
|
65
|
-
}
|
|
61
|
+
const fileContents = fs.readFileSync(file, 'utf8');
|
|
62
|
+
const lines = fileContents.split('\n');
|
|
63
|
+
if (fileContents.indexOf('// Copyright') > -1) {
|
|
64
|
+
let count = 0;
|
|
65
|
+
let line = at(lines, count);
|
|
66
|
+
let lineStartsWithSlashes = line.startsWith('//');
|
|
67
|
+
while (lineStartsWithSlashes) {
|
|
68
|
+
lineStartsWithSlashes = line.startsWith('//');
|
|
69
|
+
if (lineStartsWithSlashes) {
|
|
70
|
+
line = at(lines, ++count);
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
if (!line.startsWith('//')) {
|
|
74
|
+
count = count - 1;
|
|
75
|
+
line = at(lines, count);
|
|
76
|
+
}
|
|
77
|
+
if (line.endsWith('If not, see <http://www.gnu.org/licenses/>.') ||
|
|
78
|
+
line.endsWith('// limitations under the License.')) {
|
|
79
|
+
const newFileContents = `${header}\n${lines.slice(count + 1).join('\n')}`;
|
|
80
|
+
if (newFileContents !== fileContents) {
|
|
81
|
+
fs.writeFileSync(file, newFileContents);
|
|
82
|
+
console.log('File Updated:', file);
|
|
83
|
+
}
|
|
72
84
|
}
|
|
73
85
|
}
|
|
86
|
+
else {
|
|
87
|
+
const newFileContents = `${header}\n${fileContents}`;
|
|
88
|
+
fs.writeFileSync(file, newFileContents);
|
|
89
|
+
console.log('File Updated:', file);
|
|
90
|
+
}
|
|
74
91
|
}
|
|
75
92
|
}
|
|
76
93
|
//# sourceMappingURL=addCopyrightNotice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addCopyrightNotice.js","sourceRoot":"","sources":["../../src/scripts/addCopyrightNotice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"addCopyrightNotice.js","sourceRoot":"","sources":["../../src/scripts/addCopyrightNotice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,MAAM,GAAG;;;;;;;;;;;;kCAYmB,CAAA;AAElC,MAAM,WAAW,GAAG;IAChB,SAAS;IACT,UAAU;IACV,SAAS;IACT,SAAS;IACT,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;CACb,CAAA;AAED,MAAM,WAAW,GAAG,UAAU,EAAE,CAAA;AAEhC,MAAM,KAAK,GAAG,IAAI;KACb,IAAI,CAAC,WAAW,EAAE;IACf,GAAG,EAAE,WAAW;IAChB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE;QACJ,oBAAoB;QACpB,mBAAmB;QACnB,YAAY;QACZ,cAAc;QACd,gBAAgB;QAChB,kCAAkC;KACrC;CACJ,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAA;AAElD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;IAC5B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC3C,OAAO,CAAC,GAAG,CAAC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AG,KAAK,GAAG,CAAC,CAAA;gBACjB,IAAI,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;aAC1B;YACD,IACI,IAAI,CAAC,QAAQ,CAAC,6CAA6C,CAAC;gBAC5D,IAAI,CAAC,QAAQ,CAAC,mCAAmC,CAAC,EACpD;gBACE,MAAM,eAAe,GAAG,GAAG,MAAM,KAAK,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;gBAEzE,IAAI,eAAe,KAAK,YAAY,EAAE;oBAElC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;oBACvC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;iBACrC;aACJ;SACJ;aAAM;YAEH,MAAM,eAAe,GAAG,GAAG,MAAM,KAAK,YAAY,EAAE,CAAA;YAEpD,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CAAA;YACvC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;SACrC;KACJ;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/scripts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Dev scripts for working with prosopo packages",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"prettier": "npx prettier . --check --no-error-on-unmatched-pattern --ignore-path ../../.eslintignore",
|
|
21
21
|
"prettier:fix": "npm run prettier -- --write",
|
|
22
22
|
"lint": "npm run eslint && npm run prettier",
|
|
23
|
-
"lint:fix": "npm run eslint:fix && npm run prettier:fix"
|
|
23
|
+
"lint:fix": "npm run eslint:fix && npm run prettier:fix",
|
|
24
|
+
"license": "tsx src/scripts/addCopyrightNotice.ts check",
|
|
25
|
+
"license:fix": "tsx src/scripts/addCopyrightNotice.ts license"
|
|
24
26
|
},
|
|
25
27
|
"author": "Prosopo Limited",
|
|
26
28
|
"license": "Apache-2.0",
|
|
@@ -30,26 +32,26 @@
|
|
|
30
32
|
"@polkadot/api-contract": "10.11.2",
|
|
31
33
|
"@polkadot/types": "10.11.2",
|
|
32
34
|
"@polkadot/util-crypto": "12.6.2",
|
|
33
|
-
"@prosopo/api": "0.3.
|
|
34
|
-
"@prosopo/cli": "0.3.
|
|
35
|
-
"@prosopo/common": "0.3.
|
|
36
|
-
"@prosopo/config": "0.3.
|
|
37
|
-
"@prosopo/contract": "0.3.
|
|
38
|
-
"@prosopo/database": "0.3.
|
|
39
|
-
"@prosopo/datasets": "0.3.
|
|
40
|
-
"@prosopo/datasets-fs": "0.3.
|
|
41
|
-
"@prosopo/env": "0.3.
|
|
42
|
-
"@prosopo/file-server": "0.3.
|
|
43
|
-
"@prosopo/procaptcha": "0.3.
|
|
44
|
-
"@prosopo/procaptcha-bundle": "0.3.
|
|
45
|
-
"@prosopo/procaptcha-react": "0.3.
|
|
46
|
-
"@prosopo/provider": "0.3.
|
|
47
|
-
"@prosopo/server": "0.3.
|
|
48
|
-
"@prosopo/types": "0.3.
|
|
49
|
-
"@prosopo/types-database": "0.3.
|
|
50
|
-
"@prosopo/types-env": "0.3.
|
|
51
|
-
"@prosopo/captcha-contract": "0.3.
|
|
52
|
-
"@prosopo/util": "0.3.
|
|
35
|
+
"@prosopo/api": "0.3.3",
|
|
36
|
+
"@prosopo/cli": "0.3.3",
|
|
37
|
+
"@prosopo/common": "0.3.3",
|
|
38
|
+
"@prosopo/config": "0.3.3",
|
|
39
|
+
"@prosopo/contract": "0.3.3",
|
|
40
|
+
"@prosopo/database": "0.3.3",
|
|
41
|
+
"@prosopo/datasets": "0.3.3",
|
|
42
|
+
"@prosopo/datasets-fs": "0.3.3",
|
|
43
|
+
"@prosopo/env": "0.3.3",
|
|
44
|
+
"@prosopo/file-server": "0.3.3",
|
|
45
|
+
"@prosopo/procaptcha": "0.3.3",
|
|
46
|
+
"@prosopo/procaptcha-bundle": "0.3.3",
|
|
47
|
+
"@prosopo/procaptcha-react": "0.3.3",
|
|
48
|
+
"@prosopo/provider": "0.3.3",
|
|
49
|
+
"@prosopo/server": "0.3.3",
|
|
50
|
+
"@prosopo/types": "0.3.3",
|
|
51
|
+
"@prosopo/types-database": "0.3.3",
|
|
52
|
+
"@prosopo/types-env": "0.3.3",
|
|
53
|
+
"@prosopo/captcha-contract": "0.3.3",
|
|
54
|
+
"@prosopo/util": "0.3.3",
|
|
53
55
|
"consola": "^3.2.3",
|
|
54
56
|
"dotenv": "^16.0.3",
|
|
55
57
|
"glob": "^10.0.0",
|