@pezkuwi/dev 0.84.2

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.
Files changed (37) hide show
  1. package/.skip-deno +0 -0
  2. package/README.md +547 -0
  3. package/config/eslint.js +160 -0
  4. package/config/eslint.rules.js +214 -0
  5. package/config/prettier.cjs +22 -0
  6. package/config/rollup.js +113 -0
  7. package/config/tsconfig.json +32 -0
  8. package/config/typedoc.cjs +18 -0
  9. package/package.json +107 -0
  10. package/scripts/polkadot-ci-ghact-build.mjs +540 -0
  11. package/scripts/polkadot-ci-ghact-docs.mjs +14 -0
  12. package/scripts/polkadot-ci-ghpages-force.mjs +43 -0
  13. package/scripts/polkadot-dev-build-docs.mjs +19 -0
  14. package/scripts/polkadot-dev-build-ts.mjs +1518 -0
  15. package/scripts/polkadot-dev-circular.mjs +29 -0
  16. package/scripts/polkadot-dev-clean-build.mjs +61 -0
  17. package/scripts/polkadot-dev-contrib.mjs +74 -0
  18. package/scripts/polkadot-dev-copy-dir.mjs +44 -0
  19. package/scripts/polkadot-dev-copy-to.mjs +53 -0
  20. package/scripts/polkadot-dev-deno-map.mjs +35 -0
  21. package/scripts/polkadot-dev-run-lint.mjs +40 -0
  22. package/scripts/polkadot-dev-run-node-ts.mjs +9 -0
  23. package/scripts/polkadot-dev-run-test.mjs +163 -0
  24. package/scripts/polkadot-dev-version.mjs +143 -0
  25. package/scripts/polkadot-dev-yarn-only.mjs +11 -0
  26. package/scripts/polkadot-exec-eslint.mjs +7 -0
  27. package/scripts/polkadot-exec-ghpages.mjs +11 -0
  28. package/scripts/polkadot-exec-ghrelease.mjs +7 -0
  29. package/scripts/polkadot-exec-node-test.mjs +368 -0
  30. package/scripts/polkadot-exec-rollup.mjs +7 -0
  31. package/scripts/polkadot-exec-tsc.mjs +7 -0
  32. package/scripts/polkadot-exec-webpack.mjs +7 -0
  33. package/scripts/util.mjs +540 -0
  34. package/tsconfig.build.json +18 -0
  35. package/tsconfig.config.json +14 -0
  36. package/tsconfig.scripts.json +14 -0
  37. package/tsconfig.spec.json +18 -0
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ // @ts-expect-error For scripts we don't include @types/* definitions
6
+ import madge from 'madge';
7
+
8
+ import { exitFatal, logBin } from './util.mjs';
9
+
10
+ logBin('polkadot-dev-circular');
11
+
12
+ const res = await madge('./', { fileExtensions: ['ts', 'tsx'] });
13
+
14
+ /** @type {string[][]} */
15
+ const circular = res.circular();
16
+
17
+ if (!circular.length) {
18
+ process.stdout.write('No circular dependency found!\n');
19
+ process.exit(0);
20
+ }
21
+
22
+ const err = `Failed with ${circular.length} circular dependencies`;
23
+ const all = circular
24
+ .map((files, idx) => `${(idx + 1).toString().padStart(4)}: ${files.join(' > ')}`)
25
+ .join('\n');
26
+
27
+ process.stdout.write(`\n${err}:\n\n${all}\n\n`);
28
+
29
+ exitFatal(err);
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ import { logBin, PATHS_BUILD, rimrafSync } from './util.mjs';
9
+
10
+ const PKGS = path.join(process.cwd(), 'packages');
11
+ const DIRS = PATHS_BUILD.map((d) => `build${d}`);
12
+
13
+ logBin('polkadot-dev-clean-build');
14
+
15
+ /**
16
+ * @internal
17
+ *
18
+ * Retrieves all the files containing tsconfig.*.tsbuildinfo contained withing the directory
19
+ *
20
+ * @param {string} dir
21
+ * @returns {string[]}
22
+ */
23
+ function getPaths (dir) {
24
+ if (!fs.existsSync(dir)) {
25
+ return [];
26
+ }
27
+
28
+ return fs
29
+ .readdirSync(dir)
30
+ .reduce((all, p) => {
31
+ if (p.startsWith('tsconfig.') && p.endsWith('.tsbuildinfo')) {
32
+ all.push(path.join(dir, p));
33
+ }
34
+
35
+ return all;
36
+ }, DIRS.map((p) => path.join(dir, p)));
37
+ }
38
+
39
+ /**
40
+ * @internal
41
+ *
42
+ * Removes all the specified directories
43
+ *
44
+ * @param {string[]} dirs
45
+ */
46
+ function cleanDirs (dirs) {
47
+ dirs.forEach((d) => rimrafSync(d));
48
+ }
49
+
50
+ cleanDirs(getPaths(process.cwd()));
51
+
52
+ if (fs.existsSync(PKGS)) {
53
+ cleanDirs(getPaths(PKGS));
54
+ cleanDirs(
55
+ fs
56
+ .readdirSync(PKGS)
57
+ .map((f) => path.join(PKGS, f))
58
+ .filter((f) => fs.statSync(f).isDirectory())
59
+ .reduce((/** @type {string[]} */ res, d) => res.concat(getPaths(d)), [])
60
+ );
61
+ }
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import fs from 'node:fs';
6
+
7
+ import { execGit, logBin, mkdirpSync } from './util.mjs';
8
+
9
+ const tmpDir = 'packages/build';
10
+ const tmpFile = `${tmpDir}/CONTRIBUTORS`;
11
+
12
+ logBin('polkadot-dev-contrib');
13
+
14
+ mkdirpSync(tmpDir);
15
+ execGit(`shortlog master -e -n -s > ${tmpFile}`);
16
+
17
+ fs.writeFileSync(
18
+ 'CONTRIBUTORS',
19
+ Object
20
+ .entries(
21
+ fs
22
+ .readFileSync(tmpFile, 'utf-8')
23
+ .split('\n')
24
+ .map((l) => l.trim())
25
+ .filter((l) => !!l)
26
+ .reduce((/** @type {Record<string, { count: number; name: string; }>} */ all, line) => {
27
+ const [c, e] = line.split('\t');
28
+ const count = parseInt(c, 10);
29
+ const [name, rest] = e.split(' <');
30
+ const isExcluded = (
31
+ ['GitHub', 'Travis CI'].some((n) => name.startsWith(n)) ||
32
+ ['>', 'action@github.com>'].some((e) => rest === e) ||
33
+ [name, rest].some((n) => n.includes('[bot]'))
34
+ );
35
+
36
+ if (!isExcluded) {
37
+ let [email] = rest.split('>');
38
+
39
+ if (!all[email]) {
40
+ email = Object.keys(all).find((k) =>
41
+ name.includes(' ') &&
42
+ all[k].name === name
43
+ ) || email;
44
+ }
45
+
46
+ if (all[email]) {
47
+ all[email].count += count;
48
+ } else {
49
+ all[email] = { count, name };
50
+ }
51
+ }
52
+
53
+ return all;
54
+ }, {})
55
+ )
56
+ .sort((a, b) => {
57
+ const diff = b[1].count - a[1].count;
58
+
59
+ return diff === 0
60
+ ? a[1].name.localeCompare(b[1].name)
61
+ : diff;
62
+ })
63
+ .map(([email, { count, name }], i) => {
64
+ execGit(`log master -1 --author=${email} > ${tmpFile}-${i}`);
65
+
66
+ const commit = fs
67
+ .readFileSync(`${tmpFile}-${i}`, 'utf-8')
68
+ .split('\n')[4]
69
+ .trim();
70
+
71
+ return `${`${count}`.padStart(8)}\t${name.padEnd(30)}\t${commit}`;
72
+ })
73
+ .join('\n')
74
+ );
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { copyDirSync, exitFatal, logBin } from './util.mjs';
6
+
7
+ const argv = process.argv.slice(2);
8
+ const args = [];
9
+ let cd = '';
10
+ let flatten = false;
11
+
12
+ for (let i = 0; i < argv.length; i++) {
13
+ switch (argv[i]) {
14
+ case '--cd':
15
+ cd = argv[++i];
16
+ break;
17
+ case '--flatten':
18
+ flatten = true;
19
+ break;
20
+ default:
21
+ args.push(argv[i]);
22
+ break;
23
+ }
24
+ }
25
+
26
+ const sources = args.slice(0, args.length - 1);
27
+ const dest = args[args.length - 1];
28
+
29
+ logBin('polkadot-dev-copy-dir');
30
+
31
+ if (!sources || !dest) {
32
+ exitFatal('Expected at least one <source>... and one <destination> argument');
33
+ }
34
+
35
+ sources.forEach((src) =>
36
+ copyDirSync(
37
+ cd
38
+ ? `${cd}/${src}`
39
+ : src,
40
+ cd
41
+ ? `${cd}/${dest}${flatten ? '' : `/${src}`}`
42
+ : `${dest}${flatten ? '' : `/${src}`}`
43
+ )
44
+ );
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ import { copyDirSync, execPm, exitFatal, logBin, mkdirpSync, rimrafSync } from './util.mjs';
9
+
10
+ const args = process.argv.slice(2);
11
+
12
+ logBin('polkadot-dev-copy-to');
13
+
14
+ if (args.length !== 1) {
15
+ exitFatal('Expected one <destination> argument');
16
+ }
17
+
18
+ const dest = path.join(process.cwd(), '..', args[0], 'node_modules');
19
+
20
+ if (!fs.existsSync(dest)) {
21
+ exitFatal('Destination node_modules folder does not exist');
22
+ }
23
+
24
+ // build to ensure we actually have latest
25
+ execPm('build');
26
+
27
+ // map across what is available and copy it
28
+ fs
29
+ .readdirSync('packages')
30
+ .map((dir) => {
31
+ const pkgPath = path.join(process.cwd(), 'packages', dir);
32
+
33
+ return [pkgPath, path.join(pkgPath, 'package.json')];
34
+ })
35
+ .filter(([, jsonPath]) => fs.existsSync(jsonPath))
36
+ .map(([pkgPath, json]) => [JSON.parse(fs.readFileSync(json, 'utf8')).name, pkgPath])
37
+ .forEach(([name, pkgPath]) => {
38
+ console.log(`*** Copying ${name} to ${dest}`);
39
+
40
+ const outDest = path.join(dest, name);
41
+
42
+ // remove the destination
43
+ rimrafSync(outDest);
44
+
45
+ // create the root
46
+ mkdirpSync(outDest);
47
+
48
+ // copy the build output
49
+ copyDirSync(path.join(pkgPath, 'build'), outDest);
50
+
51
+ // copy node_modules, as available
52
+ copyDirSync(path.join(pkgPath, 'node_modules'), path.join(outDest, 'node_modules'));
53
+ });
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import fs from 'node:fs';
6
+
7
+ import { DENO_POL_PRE } from './util.mjs';
8
+
9
+ const [e, i] = fs
10
+ .readdirSync('packages')
11
+ .filter((p) => fs.existsSync(`packages/${p}/src/mod.ts`))
12
+ .sort()
13
+ .reduce((/** @type {[string[], Record<String, string>]} */ [e, i], p) => {
14
+ e.push(`export * as ${p.replace(/-/g, '_')} from '${DENO_POL_PRE}/${p}/mod.ts';`);
15
+ i[`${DENO_POL_PRE}/${p}/`] = `./packages/${p}/build-deno/`;
16
+
17
+ return [e, i];
18
+ }, [[], {}]);
19
+
20
+ if (!fs.existsSync('mod.ts')) {
21
+ fs.writeFileSync('mod.ts', `// Copyright 2017-${new Date().getFullYear()} @polkadot/dev authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// auto-generated via polkadot-dev-deno-map, do not edit\n\n// This is a Deno file, so we can allow .ts imports
22
+ /* eslint-disable import/extensions */\n\n${e.join('\n')}\n`);
23
+ }
24
+
25
+ if (fs.existsSync('import_map.in.json')) {
26
+ const o = JSON.parse(fs.readFileSync('import_map.in.json', 'utf-8'));
27
+
28
+ Object
29
+ .entries(o.imports)
30
+ .forEach(([k, v]) => {
31
+ i[k] = v;
32
+ });
33
+ }
34
+
35
+ fs.writeFileSync('import_map.json', JSON.stringify({ imports: i }, null, 2));
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import process from 'node:process';
6
+ import yargs from 'yargs';
7
+
8
+ import { __dirname, execPm, GITHUB_REPO, logBin } from './util.mjs';
9
+
10
+ const TS_CONFIG_BUILD = true;
11
+
12
+ logBin('polkadot-dev-run-lint');
13
+
14
+ // Since yargs can also be a promise, we just relax the type here completely
15
+ const argv = await yargs(process.argv.slice(2))
16
+ .options({
17
+ 'skip-eslint': {
18
+ description: 'Skips running eslint',
19
+ type: 'boolean'
20
+ },
21
+ 'skip-tsc': {
22
+ description: 'Skips running tsc',
23
+ type: 'boolean'
24
+ }
25
+ })
26
+ .strict()
27
+ .argv;
28
+
29
+ if (!argv['skip-eslint']) {
30
+ // We don't want to run with fix on CI
31
+ const extra = GITHUB_REPO
32
+ ? ''
33
+ : '--fix';
34
+
35
+ execPm(`polkadot-exec-eslint ${extra} ${process.cwd()}`);
36
+ }
37
+
38
+ if (!argv['skip-tsc']) {
39
+ execPm(`polkadot-exec-tsc --noEmit --emitDeclarationOnly false --pretty${TS_CONFIG_BUILD ? ' --project tsconfig.build.json' : ''}`);
40
+ }
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { execNodeTs, logBin } from './util.mjs';
6
+
7
+ logBin('polkadot-run-node-ts');
8
+
9
+ execNodeTs(process.argv.slice(2).join(' '));
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import process from 'node:process';
6
+
7
+ import { execNodeTs, exitFatal, exitFatalEngine, importPath, logBin, readdirSync } from './util.mjs';
8
+
9
+ // A & B are just helpers here and in the errors below
10
+ const EXT_A = ['spec', 'test'];
11
+ const EXT_B = ['ts', 'tsx', 'js', 'jsx', 'cjs', 'mjs'];
12
+
13
+ // The actual extensions we are looking for
14
+ const EXTS = EXT_A.reduce((/** @type {string[]} */ exts, s) => exts.concat(...EXT_B.map((e) => `.${s}.${e}`)), []);
15
+
16
+ logBin('polkadot-dev-run-test');
17
+
18
+ exitFatalEngine();
19
+
20
+ const cmd = [];
21
+ const nodeFlags = [];
22
+ const filters = [];
23
+
24
+ /** @type {Record<string, string[]>} */
25
+ const filtersExcl = {};
26
+ /** @type {Record<string, string[]>} */
27
+ const filtersIncl = {};
28
+
29
+ const args = process.argv.slice(2);
30
+ let testEnv = 'node';
31
+ let isDev = false;
32
+
33
+ for (let i = 0; i < args.length; i++) {
34
+ switch (args[i]) {
35
+ // when running inside a dev environment, specifically @polkadot/dev
36
+ case '--dev-build':
37
+ isDev = true;
38
+ break;
39
+
40
+ // environment, not passed-through
41
+ case '--env':
42
+ if (!['browser', 'node'].includes(args[++i])) {
43
+ throw new Error(`Invalid --env ${args[i]}, expected 'browser' or 'node'`);
44
+ }
45
+
46
+ testEnv = args[i];
47
+ break;
48
+
49
+ // internal flags with no params
50
+ case '--bail':
51
+ case '--console':
52
+ cmd.push(args[i]);
53
+ break;
54
+
55
+ // internal flags, with params
56
+ case '--logfile':
57
+ cmd.push(args[i]);
58
+ cmd.push(args[++i]);
59
+ break;
60
+
61
+ // node flags that could have additional params
62
+ case '--import':
63
+ case '--loader':
64
+ case '--require':
65
+ nodeFlags.push(args[i]);
66
+ nodeFlags.push(args[++i]);
67
+ break;
68
+
69
+ // any other non-flag arguments are passed-through
70
+ default:
71
+ if (args[i].startsWith('-')) {
72
+ throw new Error(`Unknown flag ${args[i]} found`);
73
+ }
74
+
75
+ filters.push(args[i]);
76
+
77
+ if (args[i].startsWith('^')) {
78
+ const key = args[i].slice(1);
79
+
80
+ if (filtersIncl[key]) {
81
+ delete filtersIncl[key];
82
+ } else {
83
+ filtersExcl[key] = key.split(/[\\/]/);
84
+ }
85
+ } else {
86
+ const key = args[i];
87
+
88
+ if (filtersExcl[key]) {
89
+ delete filtersExcl[key];
90
+ } else {
91
+ filtersIncl[key] = key.split(/[\\/]/);
92
+ }
93
+ }
94
+
95
+ break;
96
+ }
97
+ }
98
+
99
+ /**
100
+ * @param {string[]} parts
101
+ * @param {Record<string, string[]>} filters
102
+ * @returns {boolean}
103
+ */
104
+ function applyFilters (parts, filters) {
105
+ return Object
106
+ .values(filters)
107
+ .some((filter) =>
108
+ parts
109
+ .map((_, i) => i)
110
+ .filter((i) =>
111
+ filter[0].startsWith(':')
112
+ ? parts[i].includes(filter[0].slice(1))
113
+ : filter.length === 1
114
+ ? parts[i].startsWith(filter[0])
115
+ : parts[i] === filter[0]
116
+ )
117
+ .some((start) =>
118
+ filter.every((f, i) =>
119
+ parts[start + i] && (
120
+ f.startsWith(':')
121
+ ? parts[start + i].includes(f.slice(1))
122
+ : i === (filter.length - 1)
123
+ ? parts[start + i].startsWith(f)
124
+ : parts[start + i] === f
125
+ )
126
+ )
127
+ )
128
+ );
129
+ }
130
+
131
+ const files = readdirSync('packages', EXTS).filter((file) => {
132
+ const parts = file.split(/[\\/]/);
133
+ let isIncluded = true;
134
+
135
+ if (Object.keys(filtersIncl).length) {
136
+ isIncluded = applyFilters(parts, filtersIncl);
137
+ }
138
+
139
+ if (isIncluded && Object.keys(filtersExcl).length) {
140
+ isIncluded = !applyFilters(parts, filtersExcl);
141
+ }
142
+
143
+ return isIncluded;
144
+ });
145
+
146
+ if (files.length === 0) {
147
+ exitFatal(`No files matching *.{${EXT_A.join(', ')}}.{${EXT_B.join(', ')}} found${filters.length ? ` (filtering on ${filters.join(', ')})` : ''}`);
148
+ }
149
+
150
+ try {
151
+ const allFlags = `${importPath('@polkadot/dev/scripts/polkadot-exec-node-test.mjs')} ${[...cmd, ...files].join(' ')}`;
152
+
153
+ nodeFlags.push('--require');
154
+ nodeFlags.push(
155
+ isDev
156
+ ? `./packages/dev-test/build/cjs/${testEnv}.js`
157
+ : `@polkadot/dev-test/${testEnv}`
158
+ );
159
+
160
+ execNodeTs(allFlags, nodeFlags, false, isDev ? './packages/dev-ts/build/testCached.js' : '@polkadot/dev-ts/testCached');
161
+ } catch {
162
+ process.exit(1);
163
+ }
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+ import yargs from 'yargs';
8
+
9
+ import { execPm, exitFatal, logBin } from './util.mjs';
10
+
11
+ /** @typedef {{ dependencies?: Record<string, string>; devDependencies?: Record<string, string>; peerDependencies?: Record<string, string>; optionalDependencies?: Record<string, string>; resolutions?: Record<string, string>; name?: string; stableVersion?: string; version: string; }} PkgJson */
12
+
13
+ const TYPES = ['major', 'minor', 'patch', 'pre'];
14
+
15
+ const [type] = (
16
+ await yargs(process.argv.slice(2))
17
+ .demandCommand(1)
18
+ .argv
19
+ )._;
20
+
21
+ if (typeof type !== 'string' || !TYPES.includes(type)) {
22
+ exitFatal(`Invalid version bump "${type}", expected one of ${TYPES.join(', ')}`);
23
+ }
24
+
25
+ /**
26
+ * @param {Record<string, string>} dependencies
27
+ * @param {string[]} others
28
+ * @param {string} version
29
+ * @returns {Record<string, string>}
30
+ */
31
+ function updateDependencies (dependencies, others, version) {
32
+ return Object
33
+ .entries(dependencies)
34
+ .sort((a, b) => a[0].localeCompare(b[0]))
35
+ .reduce((/** @type {Record<string, string>} */ result, [key, value]) => {
36
+ result[key] = others.includes(key) && value !== '*'
37
+ ? value.startsWith('^')
38
+ ? `^${version}`
39
+ : version
40
+ : value;
41
+
42
+ return result;
43
+ }, {});
44
+ }
45
+
46
+ /**
47
+ * @returns {[string, PkgJson]}
48
+ */
49
+ function readCurrentPkgJson () {
50
+ const rootPath = path.join(process.cwd(), 'package.json');
51
+ const rootJson = JSON.parse(fs.readFileSync(rootPath, 'utf8'));
52
+
53
+ return [rootPath, rootJson];
54
+ }
55
+
56
+ /**
57
+ * @param {string} path
58
+ * @param {unknown} json
59
+ */
60
+ function writePkgJson (path, json) {
61
+ fs.writeFileSync(path, `${JSON.stringify(json, null, 2)}\n`);
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @param {string} version
67
+ * @param {string[]} others
68
+ * @param {string} pkgPath
69
+ * @param {Record<String, any>} json
70
+ */
71
+ function updatePackage (version, others, pkgPath, json) {
72
+ const updated = Object
73
+ .keys(json)
74
+ .reduce((/** @type {Record<String, unknown>} */ result, key) => {
75
+ if (key === 'version') {
76
+ result[key] = version;
77
+ } else if (['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies', 'resolutions'].includes(key)) {
78
+ result[key] = updateDependencies(json[key], others, version);
79
+ } else if (key !== 'stableVersion') {
80
+ result[key] = json[key];
81
+ }
82
+
83
+ return result;
84
+ }, {});
85
+
86
+ writePkgJson(pkgPath, updated);
87
+ }
88
+
89
+ function removeX () {
90
+ const [rootPath, json] = readCurrentPkgJson();
91
+
92
+ if (!json.version?.endsWith('-x')) {
93
+ return false;
94
+ }
95
+
96
+ json.version = json.version.replace('-x', '');
97
+ writePkgJson(rootPath, json);
98
+
99
+ return true;
100
+ }
101
+
102
+ function addX () {
103
+ const [rootPath, json] = readCurrentPkgJson();
104
+
105
+ if (json.version.endsWith('-x')) {
106
+ return false;
107
+ }
108
+
109
+ json.version = json.version + '-x';
110
+ writePkgJson(rootPath, json);
111
+
112
+ return true;
113
+ }
114
+
115
+ logBin('polkadot-dev-version');
116
+
117
+ const isX = removeX();
118
+
119
+ execPm(`version ${type === 'pre' ? 'prerelease' : type}`);
120
+
121
+ if (isX && type === 'pre') {
122
+ addX();
123
+ }
124
+
125
+ const [rootPath, rootJson] = readCurrentPkgJson();
126
+
127
+ updatePackage(rootJson.version, [], rootPath, rootJson);
128
+
129
+ // yarn workspaces does an OOM, manual looping takes ages
130
+ if (fs.existsSync('packages')) {
131
+ const packages = fs
132
+ .readdirSync('packages')
133
+ .map((dir) => path.join(process.cwd(), 'packages', dir, 'package.json'))
134
+ .filter((pkgPath) => fs.existsSync(pkgPath))
135
+ .map((pkgPath) => [pkgPath, JSON.parse(fs.readFileSync(pkgPath, 'utf8'))]);
136
+ const others = packages.map(([, json]) => json.name);
137
+
138
+ packages.forEach(([pkgPath, json]) => {
139
+ updatePackage(rootJson.version, others, pkgPath, json);
140
+ });
141
+ }
142
+
143
+ execPm('install');
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import process from 'node:process';
6
+
7
+ import { exitFatalYarn } from './util.mjs';
8
+
9
+ exitFatalYarn();
10
+
11
+ process.exit(0);
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { importRelative } from './util.mjs';
6
+
7
+ await importRelative('eslint', 'eslint/bin/eslint.js');
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ // Copyright 2017-2025 @polkadot/dev authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+
5
+ import { importRelative } from './util.mjs';
6
+
7
+ const ghp = await importRelative('gh-pages', 'gh-pages/bin/gh-pages.js');
8
+
9
+ await ghp.default(process.argv);
10
+
11
+ console.log('Published');