mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-04-22 11:17:59 +00:00
Initial rebrand: @polkadot -> @pezkuwi (3 packages)
- Package namespace: @polkadot/dev -> @pezkuwi/dev - Repository: polkadot-js/dev -> pezkuwichain/pezkuwi-dev - Author: Pezkuwi Team <team@pezkuwichain.io> Packages: - @pezkuwi/dev (build tools, linting, CI scripts) - @pezkuwi/dev-test (test runner) - @pezkuwi/dev-ts (TypeScript build) Upstream: polkadot-js/dev v0.83.3
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"module": "commonjs"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = { foo: 'bar' };
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export default [];
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export {};
|
||||
|
||||
throw new Error('@polkadot/dev is not meant to be imported via root. Rather if provides a set of shared dependencies, a collection of scripts, base configs and some loaders accessed via the scripts. It is only meant to be used as a shared resource by all @polkadot/* projects');
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './index.js';
|
||||
|
||||
import rollupAlias from '@rollup/plugin-alias';
|
||||
import eslint from 'eslint/use-at-your-own-risk';
|
||||
import nodeCrypto from 'node:crypto';
|
||||
|
||||
console.log(' eslint::', typeof eslint !== 'undefined');
|
||||
console.log(' nodeCrypto::', typeof nodeCrypto !== 'undefined');
|
||||
console.log('rollupAlias::', typeof rollupAlias !== 'undefined');
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Do not edit, auto-generated by @polkadot/dev
|
||||
|
||||
export const packageInfo = { name: '@polkadot/dev', path: 'auto', type: 'auto', version: '0.84.2' };
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './rootJs/index.js';
|
||||
|
||||
export const TEST_PURE = /*#__PURE__*/ 'testRoot';
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type * as testRoot from './root.js';
|
||||
|
||||
// NOTE We don't use ts-expect-error here since the build folder may or may
|
||||
// not exist (so the error may or may not be there)
|
||||
//
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore This should only run against the compiled ouput, where this should exist
|
||||
import testRootBuild from '../build/cjs/root.js';
|
||||
import { runTests } from './rootTests.js';
|
||||
|
||||
runTests(testRootBuild as unknown as typeof testRoot);
|
||||
@@ -0,0 +1,159 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
import * as testRoot from './root.js';
|
||||
import { runTests } from './rootTests.js';
|
||||
|
||||
runTests(testRoot);
|
||||
|
||||
describe('as-built output checks', (): void => {
|
||||
const buildRoot = path.join(process.cwd(), 'packages/dev/build');
|
||||
const buildFiles = fs.readdirSync(buildRoot);
|
||||
|
||||
describe('build outputs', (): void => {
|
||||
it('does not contain the *.spec.ts/js files', (): void => {
|
||||
expect(
|
||||
buildFiles.filter((f) => f.includes('.spec.'))
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('does not contain the rootRust folder', (): void => {
|
||||
expect(
|
||||
buildFiles.filter((f) => f.includes('rootRust'))
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('has the static files copied (non-duplicated)', (): void => {
|
||||
expect(
|
||||
fs.existsSync(path.join(buildRoot, 'rootStatic/kusama.svg'))
|
||||
).toBe(true);
|
||||
expect(
|
||||
fs.existsSync(path.join(buildRoot, 'cjs/rootStatic/kusama.svg'))
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('does not have stand-alone d.ts files copied', (): void => {
|
||||
expect(
|
||||
fs.existsSync(path.join(buildRoot, 'rootJs/test.json.d.ts'))
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('does have cjs + d.ts files copied', (): void => {
|
||||
expect(
|
||||
fs.existsSync(path.join(process.cwd(), 'packages/dev-test/build/globals.d.ts'))
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('code generation', (): void => {
|
||||
const jsIdx = {
|
||||
cjs: fs.readFileSync(path.join(buildRoot, 'cjs/rootJs/index.js'), { encoding: 'utf-8' }),
|
||||
esm: fs.readFileSync(path.join(buildRoot, 'rootJs/index.js'), { encoding: 'utf-8' })
|
||||
} as const;
|
||||
const idxTypes = Object.keys(jsIdx) as (keyof typeof jsIdx)[];
|
||||
|
||||
describe('numeric seperators', (): void => {
|
||||
idxTypes.forEach((type) =>
|
||||
it(`does not conatin them & has the value in ${type}`, (): void => {
|
||||
expect(
|
||||
jsIdx[type].includes('123_456_789n')
|
||||
).toBe(false);
|
||||
expect(
|
||||
jsIdx[type].includes('123456789n')
|
||||
).toBe(true);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
describe('dynamic imports', (): void => {
|
||||
idxTypes.forEach((type) =>
|
||||
it(`contains import(...) in ${type}`, (): void => {
|
||||
expect(
|
||||
jsIdx[type].includes("const { sum } = await import('@polkadot/dev/rootJs/dynamic.mjs');")
|
||||
).toBe(true);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
describe('type assertions', (): void => {
|
||||
idxTypes.forEach((type) =>
|
||||
it(`contains import(...) in ${type}`, (): void => {
|
||||
expect(
|
||||
jsIdx[type].includes(
|
||||
type === 'cjs'
|
||||
? 'require("@polkadot/dev/rootJs/testJson.json")'
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
: "import testJson from '@pezkuwi/dev/rootJs/testJson.json' assert { type: \'json\' };"
|
||||
)
|
||||
).toBe(true);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('commonjs', (): void => {
|
||||
const cjsRoot = path.join(buildRoot, 'cjs');
|
||||
|
||||
it('contains commonjs package.js inside cjs', (): void => {
|
||||
expect(
|
||||
fs
|
||||
.readFileSync(path.join(cjsRoot, 'package.json'), { encoding: 'utf-8' })
|
||||
.includes('"type": "commonjs"')
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('contains cjs/sample.js', (): void => {
|
||||
expect(
|
||||
fs
|
||||
.readFileSync(path.join(cjsRoot, 'sample.js'), { encoding: 'utf-8' })
|
||||
.includes("module.exports = { foo: 'bar' };")
|
||||
).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('deno', (): void => {
|
||||
const denoRoot = path.join(process.cwd(), 'packages/dev/build-deno');
|
||||
const denoMod = fs.readFileSync(path.join(denoRoot, 'mod.ts'), 'utf-8');
|
||||
|
||||
it('has *.ts imports', (): void => {
|
||||
expect(
|
||||
denoMod.includes("import './index.ts';")
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('has node: imports', (): void => {
|
||||
expect(
|
||||
denoMod.includes("import nodeCrypto from 'node:crypto';")
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('has deno.land/x imports', (): void => {
|
||||
expect(
|
||||
fs
|
||||
.readFileSync(path.join(denoRoot, 'rootJs/augmented.ts'))
|
||||
.includes("declare module 'https://deno.land/x/polkadot/dev/types.ts' {")
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
// See https://github.com/denoland/deno/issues/18557
|
||||
// NOTE: When available, the toBe(false) should be toBe(true)
|
||||
describe.todo('npm: prefixes', (): void => {
|
||||
it('has npm: imports', (): void => {
|
||||
expect(
|
||||
/import rollupAlias from 'npm:@rollup\/plugin-alias@\^\d\d?\.\d\d?\.\d\d?';/.test(denoMod)
|
||||
).toBe(false); // true);
|
||||
});
|
||||
|
||||
it('has npm: imports with paths', (): void => {
|
||||
expect(
|
||||
/import eslint from 'npm:eslint@\^\d\d?\.\d\d?\.\d\d?\/use-at-your-own-risk';/.test(denoMod)
|
||||
).toBe(false); // true);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export class Clazz {
|
||||
#something = 123_456_789;
|
||||
|
||||
readonly and: number;
|
||||
|
||||
static staticProperty = 'foobar';
|
||||
static staticFunction = (): string|null => Clazz.staticProperty;
|
||||
|
||||
/**
|
||||
* @param and the number we should and with
|
||||
*/
|
||||
constructor (and: number) {
|
||||
this.and = and;
|
||||
this.#something = this.#something & and;
|
||||
}
|
||||
|
||||
get something (): number {
|
||||
return this.#something;
|
||||
}
|
||||
|
||||
async doAsync (): Promise<boolean> {
|
||||
const res = await new Promise<boolean>((resolve) => resolve(true));
|
||||
|
||||
console.log(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sets something to something
|
||||
* @param something The addition
|
||||
*/
|
||||
setSomething = (something?: number): number => {
|
||||
this.#something = (something ?? 123_456) & this.and;
|
||||
|
||||
return this.#something;
|
||||
};
|
||||
|
||||
toString (): string {
|
||||
return `something=${this.#something}`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import React from 'react';
|
||||
|
||||
import Jsx from './Jsx.js';
|
||||
|
||||
describe('react testing', () => {
|
||||
it('shows the children when the checkbox is checked', () => {
|
||||
const testMessage = 'Test Message';
|
||||
|
||||
render(<Jsx>{testMessage}</Jsx>);
|
||||
|
||||
assert.equal(screen.queryByText(testMessage), null);
|
||||
|
||||
fireEvent.click(screen.getByLabelText(/show/i));
|
||||
|
||||
assert.notEqual(screen.getByText(testMessage), null);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Adapted from https://github.com/testing-library/react-testing-library#basic-example
|
||||
|
||||
import type { Props } from './JsxChild.js';
|
||||
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { styled } from 'styled-components';
|
||||
|
||||
import Child from './JsxChild.js';
|
||||
|
||||
function Hidden ({ children, className }: Props): React.ReactElement<Props> {
|
||||
const [isMessageVisible, setMessageVisibility] = useState(false);
|
||||
|
||||
const onShow = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) =>
|
||||
setMessageVisibility(e.target.checked),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledDiv className={className}>
|
||||
<label htmlFor='toggle'>Show Message</label>
|
||||
<input
|
||||
checked={isMessageVisible}
|
||||
id='toggle'
|
||||
onChange={onShow}
|
||||
type='checkbox'
|
||||
/>
|
||||
{isMessageVisible && (
|
||||
<>
|
||||
{children}
|
||||
<Child label='hello' />
|
||||
</>
|
||||
)}
|
||||
</StyledDiv>
|
||||
);
|
||||
}
|
||||
|
||||
const StyledDiv = styled.div`
|
||||
background: red;
|
||||
`;
|
||||
|
||||
export default React.memo(Hidden);
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
|
||||
export interface Props {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
function Child ({ children, className, label }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<div className={className}>
|
||||
{label || ''}{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Child);
|
||||
@@ -0,0 +1,13 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
/** This tests augmentation outputs, e.g. as used in the polkadot-js/api */
|
||||
|
||||
export interface Something {
|
||||
bar: string;
|
||||
foo: string;
|
||||
}
|
||||
|
||||
declare module '@polkadot/dev/types' {
|
||||
const blah: string;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Returns the sum of 2 numbers
|
||||
*
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @returns {number}
|
||||
*/
|
||||
export function sum (a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/** This should appear as-is in the output with: 1. extension added, 2. augmented.d.ts correct */
|
||||
import './augmented.js';
|
||||
|
||||
/** This import should appear as-in in the ouput (cjs without asserts) */
|
||||
import testJson from '@pezkuwi/dev/rootJs/testJson.json' assert { type: 'json' };
|
||||
|
||||
/** Double double work, i.e. re-exports */
|
||||
export { Clazz } from './Clazz.js';
|
||||
|
||||
/** Function to ensure that BigInt does not have the Babel Math.pow() transform */
|
||||
export function bigIntExp (): bigint {
|
||||
// 123_456n * 137_858_491_849n
|
||||
return 123_456_789n * (13n ** 10n);
|
||||
}
|
||||
|
||||
/** Function to ensure that dynamic imports work */
|
||||
export async function dynamic (a: number, b: number): Promise<number> {
|
||||
// NOTE we go via this path so it points to the same location in both ESM
|
||||
// and CJS output (a './dynamic' import would be different otherwise)
|
||||
const { sum } = await import('@polkadot/dev/rootJs/dynamic.mjs');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return sum(a, b);
|
||||
}
|
||||
|
||||
/** Function to ensure we have json correctly imported */
|
||||
export function json (): string {
|
||||
return testJson.test.json;
|
||||
}
|
||||
|
||||
/** Check support for the ?? operator */
|
||||
export function jsOpExp (a?: number): number {
|
||||
const defaults = {
|
||||
a: 42,
|
||||
b: 43,
|
||||
c: 44
|
||||
};
|
||||
|
||||
return a ?? defaults.a;
|
||||
}
|
||||
|
||||
/** This is an actual check to ensure PURE is all-happy */
|
||||
export const pureOpExp = /*#__PURE__*/ jsOpExp();
|
||||
|
||||
const fooA = 1;
|
||||
const fooB = 2;
|
||||
const fooC = 3;
|
||||
const fooD = 4;
|
||||
|
||||
export { fooA, fooB, fooC, fooD };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/** This file should not be in the compiled output */
|
||||
|
||||
declare module './testJson.json' {
|
||||
declare let contents: { test: { json: 'works' } };
|
||||
export default contents;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"test": {
|
||||
"json": "works"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/// this should not appear in the final output
|
||||
@@ -0,0 +1 @@
|
||||
/// this should not appear in the final output
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import * as testRoot from './root.js';
|
||||
import { runTests } from './rootTests.js';
|
||||
|
||||
/** This is run against the sources */
|
||||
runTests(testRoot);
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 441 441"><defs><style>.cls-1{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#fff;}</style></defs><title>kusama-ksm-logo</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><rect class="cls-1" x="0.5" y="0.5" width="440" height="440"/><path class="cls-2" d="M373.6,127.4c-5.2-4.1-11.4-9.7-22.7-11.1-10.6-1.4-21.4,5.7-28.7,10.4s-21.1,18.5-26.8,22.7-20.3,8.1-43.8,22.2-115.7,73.3-115.7,73.3l24,.3-107,55.1H63.6L48.2,312s13.6,3.6,25-3.6v3.3s127.4-50.2,152-37.2l-15,4.4c1.3,0,25.5,1.6,25.5,1.6a34.34,34.34,0,0,0,15.4,24.8c14.6,9.6,14.9,14.9,14.9,14.9s-7.6,3.1-7.6,7c0,0,11.2-3.4,21.6-3.1a82.64,82.64,0,0,1,19.5,3.1s-.8-4.2-10.9-7-20.1-13.8-25-19.8a28,28,0,0,1-4.1-27.4c3.5-9.1,15.7-14.1,40.9-27.1,29.7-15.4,36.5-26.8,40.7-35.7s10.4-26.6,13.9-34.9c4.4-10.7,9.8-16.4,14.3-19.8s24.5-10.9,24.5-10.9S378.5,131.3,373.6,127.4Z"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 912 B |
@@ -0,0 +1,60 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
/* global describe, expect, it */
|
||||
|
||||
import type * as testRoot from './root.js';
|
||||
|
||||
export function runTests ({ Clazz, TEST_PURE, bigIntExp, dynamic, jsOpExp, json }: typeof testRoot): void {
|
||||
describe('Clazz', (): void => {
|
||||
it('has staticProperty', (): void => {
|
||||
expect(Clazz.staticProperty).toBe('foobar');
|
||||
});
|
||||
|
||||
it('creates an instance with get/set', (): void => {
|
||||
const c = new Clazz(456);
|
||||
|
||||
expect(c.something).toBe(123_456_789 & 456);
|
||||
|
||||
c.setSomething(123);
|
||||
|
||||
expect(c.something).toBe(123 & 456);
|
||||
});
|
||||
});
|
||||
|
||||
describe('TEST_PURE', (): void => {
|
||||
it('should have the correct value', (): void => {
|
||||
expect(TEST_PURE).toBe('testRoot');
|
||||
});
|
||||
});
|
||||
|
||||
describe('dynamic()', (): void => {
|
||||
it('should allow dynamic import usage', async (): Promise<void> => {
|
||||
expect(await dynamic(5, 37)).toBe(42);
|
||||
});
|
||||
});
|
||||
|
||||
describe('bigIntExp()', (): void => {
|
||||
it('should return the correct value', (): void => {
|
||||
expect(bigIntExp()).toBe(123_456_789n * 137_858_491_849n);
|
||||
});
|
||||
});
|
||||
|
||||
describe('jsOpExp', (): void => {
|
||||
it('handles 0 ?? 42 correctly', (): void => {
|
||||
expect(jsOpExp(0)).toBe(0);
|
||||
});
|
||||
|
||||
it('handles undefined ?? 42 correctly', (): void => {
|
||||
expect(jsOpExp()).toBe(42);
|
||||
});
|
||||
});
|
||||
|
||||
describe('json()', (): void => {
|
||||
it('should return the correct value', (): void => {
|
||||
expect(json()).toBe('works');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export type EchoString = string;
|
||||
|
||||
export type BlahType = number;
|
||||
Reference in New Issue
Block a user