Tidy package.json (#32487)
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -21,7 +21,7 @@ jobs:
|
|||||||
run: "pnpm install --frozen-lockfile"
|
run: "pnpm install --frozen-lockfile"
|
||||||
|
|
||||||
- name: Fetch Jitsi
|
- name: Fetch Jitsi
|
||||||
run: "pnpm update:jitsi"
|
run: "pnpm vendor:jitsi"
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8
|
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8
|
||||||
|
|||||||
+6
-20
@@ -9,23 +9,6 @@
|
|||||||
},
|
},
|
||||||
"license": "SEE LICENSE IN README.md",
|
"license": "SEE LICENSE IN README.md",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
|
||||||
"lib",
|
|
||||||
"res",
|
|
||||||
"src",
|
|
||||||
"webpack.config.js",
|
|
||||||
"scripts",
|
|
||||||
"docs",
|
|
||||||
"release.sh",
|
|
||||||
"deploy",
|
|
||||||
"CHANGELOG.md",
|
|
||||||
"CONTRIBUTING.rst",
|
|
||||||
"LICENSE",
|
|
||||||
"README.md",
|
|
||||||
"AUTHORS.rst",
|
|
||||||
"package.json"
|
|
||||||
],
|
|
||||||
"style": "bundle.css",
|
|
||||||
"matrix_i18n_extra_translation_funcs": [
|
"matrix_i18n_extra_translation_funcs": [
|
||||||
"UserFriendlyError"
|
"UserFriendlyError"
|
||||||
],
|
],
|
||||||
@@ -34,11 +17,11 @@
|
|||||||
"i18n:sort": "matrix-sort-i18n src/i18n/strings/en_EN.json && pnpm --dir packages/shared-components i18n:sort",
|
"i18n:sort": "matrix-sort-i18n src/i18n/strings/en_EN.json && pnpm --dir packages/shared-components i18n:sort",
|
||||||
"i18n:lint": "matrix-i18n-lint && prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null && pnpm --dir packages/shared-components i18n:lint",
|
"i18n:lint": "matrix-i18n-lint && prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null && pnpm --dir packages/shared-components i18n:lint",
|
||||||
"i18n:diff": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && pnpm i18n && matrix-compare-i18n-files src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json",
|
"i18n:diff": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && pnpm i18n && matrix-compare-i18n-files src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json",
|
||||||
"make-component": "node scripts/make-react-component.js",
|
|
||||||
"rethemendex": "sh ./res/css/rethemendex.sh",
|
"rethemendex": "sh ./res/css/rethemendex.sh",
|
||||||
"build": "nx build element-web",
|
"build": "nx build element-web",
|
||||||
"build-stats": "nx build-stats element-web --args=\"--json=webpack-stats.json\"",
|
"build-stats": "nx build-stats element-web --args=\"--json=webpack-stats.json\"",
|
||||||
"build:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js && mv src/vector/modernizr.js src/vector/modernizr.cjs",
|
"vendor:modernizr": "modernizr -c .modernizr.json -d src/vector/modernizr.js && mv src/vector/modernizr.js src/vector/modernizr.cjs",
|
||||||
|
"vendor:jitsi": "curl -s https://meet.element.io/libs/external_api.min.js > ./res/jitsi_external_api.min.js",
|
||||||
"dist": "./scripts/package.sh",
|
"dist": "./scripts/package.sh",
|
||||||
"start": "nx start element-web",
|
"start": "nx start element-web",
|
||||||
"lint": "pnpm lint:types && pnpm lint:js && pnpm lint:style && pnpm lint:workflows",
|
"lint": "pnpm lint:types && pnpm lint:js && pnpm lint:style && pnpm lint:workflows",
|
||||||
@@ -54,7 +37,6 @@
|
|||||||
"test:playwright:screenshots": "playwright-screenshots --project=Chrome",
|
"test:playwright:screenshots": "playwright-screenshots --project=Chrome",
|
||||||
"coverage": "pnpm test --coverage",
|
"coverage": "pnpm test --coverage",
|
||||||
"analyse:webpack-bundles": "webpack-bundle-analyzer webpack-stats.json webapp",
|
"analyse:webpack-bundles": "webpack-bundle-analyzer webpack-stats.json webapp",
|
||||||
"update:jitsi": "curl -s https://meet.element.io/libs/external_api.min.js > ./res/jitsi_external_api.min.js",
|
|
||||||
"postinstall": "node scripts/pnpm-link.ts"
|
"postinstall": "node scripts/pnpm-link.ts"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
@@ -289,6 +271,10 @@
|
|||||||
"onlyBuiltDependencies": [
|
"onlyBuiltDependencies": [
|
||||||
"matrix-js-sdk"
|
"matrix-js-sdk"
|
||||||
],
|
],
|
||||||
|
"ignoredBuiltDependencies": [
|
||||||
|
"@sentry/cli",
|
||||||
|
"nx"
|
||||||
|
],
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@vector-im/matrix-wysiwyg": "patches/@vector-im__matrix-wysiwyg.patch",
|
"@vector-im/matrix-wysiwyg": "patches/@vector-im__matrix-wysiwyg.patch",
|
||||||
"react-blurhash": "patches/react-blurhash.patch",
|
"react-blurhash": "patches/react-blurhash.patch",
|
||||||
|
|||||||
@@ -1,152 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
const fs = require("fs/promises");
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unsophisticated script to create a styled, unit-tested react component.
|
|
||||||
* -filePath / -f : path to the component to be created, including new component name, excluding extension, relative to src
|
|
||||||
* -withStyle / -s : optional, flag to create a style file for the component. Defaults to false.
|
|
||||||
*
|
|
||||||
* eg:
|
|
||||||
* ```
|
|
||||||
* node srcipts/make-react-component.js -f components/toasts/NewToast -s
|
|
||||||
* ```
|
|
||||||
* creates files:
|
|
||||||
* - src/components/toasts/NewToast.tsx
|
|
||||||
* - test/components/toasts/NewToast-test.tsx
|
|
||||||
* - res/css/components/toasts/_NewToast.pcss
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
const TEMPLATES = {
|
|
||||||
COMPONENT: `
|
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
interface Props {}
|
|
||||||
|
|
||||||
const %%ComponentName%%: React.FC<Props> = () => {
|
|
||||||
return <div className='mx_%%ComponentName%%' />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default %%ComponentName%%;
|
|
||||||
`,
|
|
||||||
TEST: `
|
|
||||||
import React from "react";
|
|
||||||
import { render } from "jest-matrix-react";
|
|
||||||
|
|
||||||
import %%ComponentName%% from '%%RelativeComponentPath%%';
|
|
||||||
|
|
||||||
describe("<%%ComponentName%% />", () => {
|
|
||||||
const defaultProps = {};
|
|
||||||
const getComponent = (props = {}) =>
|
|
||||||
render(<%%ComponentName%% {...defaultProps} {...props} />);
|
|
||||||
|
|
||||||
it("matches snapshot", () => {
|
|
||||||
const { asFragment } = getComponent();
|
|
||||||
expect(asFragment()).toMatchSnapshot()();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
`,
|
|
||||||
STYLE: `
|
|
||||||
.mx_%%ComponentName%% {
|
|
||||||
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
};
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
alias: {
|
|
||||||
filePath: "f",
|
|
||||||
withStyle: "s",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const args = require("minimist")(process.argv, options);
|
|
||||||
|
|
||||||
const ensureDirectoryExists = async (filePath) => {
|
|
||||||
const dirName = path.parse(filePath).dir;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await fs.access(dirName);
|
|
||||||
return;
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
await fs.mkdir(dirName, { recursive: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
const makeFile = async ({ filePath, componentName, extension, base, template, prefix, componentFilePath }) => {
|
|
||||||
const newFilePath = path.join(
|
|
||||||
base,
|
|
||||||
path.dirname(filePath),
|
|
||||||
`${prefix || ""}${path.basename(filePath)}${extension}`,
|
|
||||||
);
|
|
||||||
await ensureDirectoryExists(newFilePath);
|
|
||||||
|
|
||||||
const relativePathToComponent = path.parse(path.relative(path.dirname(newFilePath), componentFilePath || ""));
|
|
||||||
const importComponentPath = path.join(relativePathToComponent.dir, relativePathToComponent.name);
|
|
||||||
|
|
||||||
try {
|
|
||||||
await fs.writeFile(newFilePath, fillTemplate(template, componentName, importComponentPath), { flag: "wx" });
|
|
||||||
console.log(`Created ${path.relative(process.cwd(), newFilePath)}`);
|
|
||||||
return newFilePath;
|
|
||||||
} catch (error) {
|
|
||||||
if (error.code === "EEXIST") {
|
|
||||||
console.log(`File already exists ${path.relative(process.cwd(), newFilePath)}`);
|
|
||||||
return newFilePath;
|
|
||||||
} else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fillTemplate = (template, componentName, relativeComponentFilePath, skinnedSdkPath) =>
|
|
||||||
template
|
|
||||||
.replace(/%%ComponentName%%/g, componentName)
|
|
||||||
.replace(/%%RelativeComponentPath%%/g, relativeComponentFilePath);
|
|
||||||
|
|
||||||
const makeReactComponent = async () => {
|
|
||||||
const { filePath, withStyle } = args;
|
|
||||||
|
|
||||||
if (!filePath) {
|
|
||||||
throw new Error("No file path provided, did you forget -f?");
|
|
||||||
}
|
|
||||||
|
|
||||||
const componentName = filePath.split("/").slice(-1).pop();
|
|
||||||
|
|
||||||
const componentFilePath = await makeFile({
|
|
||||||
filePath,
|
|
||||||
componentName,
|
|
||||||
base: "src",
|
|
||||||
extension: ".tsx",
|
|
||||||
template: TEMPLATES.COMPONENT,
|
|
||||||
});
|
|
||||||
await makeFile({
|
|
||||||
filePath,
|
|
||||||
componentFilePath,
|
|
||||||
componentName,
|
|
||||||
base: "test",
|
|
||||||
extension: "-test.tsx",
|
|
||||||
template: TEMPLATES.TEST,
|
|
||||||
componentName,
|
|
||||||
});
|
|
||||||
if (withStyle) {
|
|
||||||
await makeFile({
|
|
||||||
filePath,
|
|
||||||
componentName,
|
|
||||||
base: "res/css",
|
|
||||||
prefix: "_",
|
|
||||||
extension: ".pcss",
|
|
||||||
template: TEMPLATES.STYLE,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Wrapper since await at the top level is not well supported yet
|
|
||||||
function run() {
|
|
||||||
(async function () {
|
|
||||||
await makeReactComponent();
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
||||||
run();
|
|
||||||
return;
|
|
||||||
Reference in New Issue
Block a user