chore(root): cleanup and update dependencies
This commit is contained in:
parent
519cb9c91a
commit
aea90ae036
51 changed files with 5855 additions and 57754 deletions
7
.changeset/big-rings-heal.md
Normal file
7
.changeset/big-rings-heal.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
'providence-analytics': minor
|
||||
---
|
||||
|
||||
- Added `optimised-glob` util: a drop-in replacement for globby. It's faster, smaller and has zero dependencies
|
||||
- Added `fs-adapter` util, allowing to provide a virtual fs instead of the default
|
||||
- BREAKING: Cleanup of code and dependencies, removing deprecated cli commands
|
||||
|
|
@ -51,20 +51,4 @@ module.exports = {
|
|||
env: {
|
||||
es2020: true,
|
||||
},
|
||||
// ignores: [
|
||||
// 'node_modules',
|
||||
// 'coverage/',
|
||||
// 'bundlesize/',
|
||||
// '.history/',
|
||||
// 'storybook-static/',
|
||||
// '*.d.ts',
|
||||
// '_site-dev',
|
||||
// '_site',
|
||||
// 'docs/_merged_*',
|
||||
// 'patches/',
|
||||
|
||||
// '/docs/_assets/scoped-custom-element-registry.min.js',
|
||||
// '/docs/_assets/scoped-custom-element-registry.min.js.map',
|
||||
// '/docs/_merged_assets/scoped-custom-element-registry.min.js',
|
||||
// ],
|
||||
};
|
||||
|
|
|
|||
73
.github/workflows/verify-pr.yml
vendored
Normal file
73
.github/workflows/verify-pr.yml
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
name: Verify changes
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
name: Verify changes
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Sanity check
|
||||
run: node ./scripts/lock-scan.mjs
|
||||
|
||||
- name: Setup Node 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
# - name: Bundlesize
|
||||
# run: npm run bundlesize
|
||||
|
||||
browser-tests:
|
||||
name: Browser tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node 18.x
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.x
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci
|
||||
|
||||
- uses: microsoft/playwright-github-action@v1
|
||||
|
||||
- name: Test
|
||||
run: npm run test:browser
|
||||
|
||||
node-tests:
|
||||
name: Node tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x, 18.x]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci --force
|
||||
|
||||
- name: Test
|
||||
run: npm run test:node
|
||||
93
.github/workflows/verify.yml
vendored
93
.github/workflows/verify.yml
vendored
|
|
@ -1,93 +0,0 @@
|
|||
name: Verify changes
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
verify:
|
||||
name: Verify changes
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Sanity check
|
||||
run: node ./scripts/lock-scan.js
|
||||
|
||||
- name: Setup Node 16.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Bundlesize
|
||||
run: npm run bundlesize
|
||||
|
||||
browser-tests:
|
||||
name: Browser tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node 16.x
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 16.x
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci
|
||||
|
||||
- uses: microsoft/playwright-github-action@v1
|
||||
|
||||
- name: Test
|
||||
run: npm run test:browser
|
||||
|
||||
node-tests:
|
||||
name: Node tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x]
|
||||
os: [ubuntu-latest]
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci
|
||||
|
||||
- name: Test
|
||||
run: npm run test:node
|
||||
|
||||
# Note this is a duplicate of the matrix (so we have 2 1x1 matrices). Up for improvement...
|
||||
node-tests-windows:
|
||||
name: Node tests
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x]
|
||||
os: [windows-latest]
|
||||
steps:
|
||||
- uses: google/wireit@setup-github-actions-caching/v1
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install --ci
|
||||
|
||||
- name: Test
|
||||
run: npm run test:node
|
||||
|
|
@ -4,7 +4,6 @@ module.exports = {
|
|||
'*.md': [
|
||||
'prettier --write',
|
||||
"markdownlint --ignore '{.github/**/*.md,.changeset/*.md,**/CHANGELOG.md,packages/ui/_legacy-changelogs/*.md}'",
|
||||
'git add',
|
||||
],
|
||||
'package-lock.json': ['node ./scripts/lock-scan.js'],
|
||||
'*package.json': absolutePaths => {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class MdRipple extends LitElement {
|
|||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this.removeEventListener('mousedown', this.__onRipple);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -612,7 +612,7 @@ However, the validation system also supports three non blocking validation feedb
|
|||
- **error**: blocking the field from being submitted to the server. For example:
|
||||
"Please enter an amount higher than 1000,00 euro."
|
||||
- **warning**: something looks wrong, but it is not blocking. For example an optional email input:
|
||||
"Please enter a valid e-mail address in the format "name@example.com"."
|
||||
"Please enter a valid e-mail address in the format `name@example.com`."
|
||||
- **info**: shows extra information. For example a message of a scheduled payment planner:
|
||||
"Ends on 15/05/2020 after 5 payments."
|
||||
- **success**: will only be triggered if there was a Message from one of the above validation types and is now correct. For example: "Ok, correct."
|
||||
|
|
|
|||
|
|
@ -99,15 +99,6 @@ export const placementGlobal = () => {
|
|||
|
||||
## popperConfig
|
||||
|
||||
/** Viewport configuration. Will be used when placementMode is 'global' \*/
|
||||
viewportConfig?: ViewportConfig;
|
||||
/** Hides other overlays when multiple are opened (currently exclusive to globalOverlayController) _/
|
||||
isBlocking?: boolean;
|
||||
/\*\* Will align contentNode with referenceNode (invokerNode by default) for local overlays. Usually needed for dropdowns. 'max' will prevent contentNode from exceeding width of referenceNode, 'min' guarantees that contentNode will be at least as wide as referenceNode. 'full' will make sure that the invoker width always is the same. _/
|
||||
inheritsReferenceWidth?: 'max' | 'full' | 'min' | 'none';
|
||||
/\*_ Change the default of 9999 _/
|
||||
zIndex?: number;
|
||||
|
||||
| Prop | Description | Type | | | |
|
||||
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- | --- | --- | --- |
|
||||
| placementMode | Determines the positioning anchor (viewport vs invokerNode/referenceNode) | 'global'\|'local' | | | |
|
||||
|
|
|
|||
24250
package-lock.json
generated
24250
package-lock.json
generated
File diff suppressed because it is too large
Load diff
37792
package-lock.jsonx
37792
package-lock.jsonx
File diff suppressed because it is too large
Load diff
135
package.json
135
package.json
|
|
@ -22,15 +22,14 @@
|
|||
"lint:versions": "node ./scripts/lint-versions.js",
|
||||
"prepare": "husky install",
|
||||
"release": "changeset publish",
|
||||
"rm-all-node_modules": "npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules",
|
||||
"rocket:build": "rocket build",
|
||||
"rocket:build:start": "web-dev-server --root-dir _site --open",
|
||||
"repo:clean-slate": "git clean -dfX",
|
||||
"repo:diff-package-lock": "npx diff-package-lock",
|
||||
"start": "rocket start",
|
||||
"test": "run-p test:browser test:node",
|
||||
"test:browser": "web-test-runner --coverage",
|
||||
"test:browserstack": "web-test-runner --config ./web-test-runner-browserstack.config.js",
|
||||
"test:node": "npm run test:node --workspaces --if-present",
|
||||
"test:screenshots": "rimraf screenshots/.diff/ && rimraf screenshots/.current/ && mocha --require scripts/screenshots/bootstrap.js --exit --timeout 10000 \"packages/**/test/*.screenshots-test.js\"",
|
||||
"test:screenshots": "npx rimraf screenshots/.diff/ && npx rimraf screenshots/.current/ && mocha --require scripts/screenshots/bootstrap.js --exit --timeout 10000 \"packages/**/test/*.screenshots-test.js\"",
|
||||
"test:screenshots:update": "cross-env UPDATE_SCREENSHOTS=true npm run test:screenshots",
|
||||
"types": "npm run types --workspaces --if-present",
|
||||
"types-check-only": "npm run types-check-only --workspaces --if-present"
|
||||
|
|
@ -40,71 +39,57 @@
|
|||
"packages-node/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.21.3",
|
||||
"@babel/core": "^7.24.5",
|
||||
"@bundled-es-modules/fetch-mock": "^6.5.2",
|
||||
"@changesets/cli": "^2.26.1",
|
||||
"@custom-elements-manifest/analyzer": "^0.8.0",
|
||||
"@open-wc/building-rollup": "^1.10.0",
|
||||
"@open-wc/eslint-config": "^10.0.0",
|
||||
"@changesets/cli": "^2.27.1",
|
||||
"@custom-elements-manifest/analyzer": "^0.10.2",
|
||||
"@open-wc/building-rollup": "^2.2.3",
|
||||
"@open-wc/eslint-config": "^12.0.3",
|
||||
"@open-wc/scoped-elements": "^3.0.5",
|
||||
"@open-wc/testing": "^3.1.7",
|
||||
"@open-wc/testing-helpers": "^2.2.0",
|
||||
"@rocket/blog": "^0.4.0",
|
||||
"@open-wc/testing": "^4.0.0",
|
||||
"@open-wc/testing-helpers": "^3.0.1",
|
||||
"@rocket/blog": "0.4.0",
|
||||
"@rocket/cli": "^0.10.2",
|
||||
"@rocket/launch": "^0.6.0",
|
||||
"@rocket/search": "^0.5.1",
|
||||
"@types/autosize": "^4.0.3",
|
||||
"@types/chai-as-promised": "^7.1.5",
|
||||
"@types/chai-dom": "^0.0.8",
|
||||
"@types/convert-source-map": "^1.5.2",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/glob": "^7.1.3",
|
||||
"@types/istanbul-reports": "^3.0.1",
|
||||
"@types/mocha": "^10.0.1",
|
||||
"@types/prettier": "^2.7.2",
|
||||
"@web/dev-server": "^0.4.2",
|
||||
"@types/chai-as-promised": "^7.1.8",
|
||||
"@types/chai-dom": "^1.11.3",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/glob": "^8.1.0",
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@types/prettier": "^2.7.3",
|
||||
"@web/dev-server-legacy": "^0.1.7",
|
||||
"@web/test-runner": "^0.15.2",
|
||||
"@web/test-runner-browserstack": "^0.5.1",
|
||||
"@web/test-runner-commands": "^0.6.5",
|
||||
"@web/test-runner-playwright": "^0.9.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "^0.0.8",
|
||||
"@yarnpkg/lockfile": "^1.1.0",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"@web/test-runner": "^0.18.1",
|
||||
"@web/test-runner-browserstack": "^0.7.1",
|
||||
"@web/test-runner-commands": "^0.9.0",
|
||||
"@web/test-runner-playwright": "^0.11.0",
|
||||
"@webcomponents/scoped-custom-element-registry": "^0.0.9",
|
||||
"bundlesize": "^1.0.0-beta.2",
|
||||
"cem-plugin-vs-code-custom-data-generator": "^1.4.1",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"changeset": "^0.2.6",
|
||||
"cross-env": "^7.0.2",
|
||||
"es6-promisify": "^6.1.1",
|
||||
"cem-plugin-vs-code-custom-data-generator": "^1.4.2",
|
||||
"chai": "^4.4.1",
|
||||
"chai-as-promised": "^7.1.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-lit": "^1.11.0",
|
||||
"eslint-plugin-lit-a11y": "^4.1.2",
|
||||
"eslint-plugin-wc": "^2.1.0",
|
||||
"globby": "^13.1.3",
|
||||
"husky": "^6.0.0",
|
||||
"lint-staged": "^10.5.4",
|
||||
"globby": "^14.0.1",
|
||||
"husky": "^9.0.11",
|
||||
"lint-staged": "^15.2.2",
|
||||
"looks-same": "^7.3.0",
|
||||
"markdownlint-cli": "^0.17.0",
|
||||
"minimist": "^1.2.6",
|
||||
"mkdirp-promise": "^5.0.1",
|
||||
"mocha": "^10.1.0",
|
||||
"markdownlint-cli": "^0.40.0",
|
||||
"mocha": "^10.4.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"playwright": "^1.32.1",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"prettier": "^2.0.5",
|
||||
"prettier-package-json": "^2.1.3",
|
||||
"remark-html": "^13.0.1",
|
||||
"rimraf": "^2.6.3",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-package-json": "^2.8.0",
|
||||
"remark-html": "^13.0.2",
|
||||
"rollup": "^2.79.1",
|
||||
"semver": "^7.5.2",
|
||||
"sinon": "^7.5.0",
|
||||
"ssl-root-cas": "^1.3.1",
|
||||
"semver": "^7.6.2",
|
||||
"sinon": "^17.0.2",
|
||||
"typescript": "^4.9.5",
|
||||
"wireit": "^0.7.2"
|
||||
"wireit": "^0.14.4"
|
||||
},
|
||||
"bundlesize": [
|
||||
{
|
||||
|
|
@ -114,11 +99,57 @@
|
|||
],
|
||||
"comments": {
|
||||
"overrides": {
|
||||
"//": [
|
||||
"For best compatibility, we sometimes need to override a package version depended upon by multiple packages."
|
||||
],
|
||||
"sharp": [
|
||||
"Version of 'sharp' package we get via '@rocket/cli' is too old to be built on a Mac.",
|
||||
"But updating package '@rocket-cli' causes our portal to break. Reason unknown.",
|
||||
"So, we override the sharp version in here until '@rocket-cli' can be updated."
|
||||
]
|
||||
},
|
||||
"olderVersions": {
|
||||
"//": [
|
||||
"Our aim is to keep all depencies up-to-date(for maintainability, performance and security).",
|
||||
"We use [npm-outdated](https://marketplace.visualstudio.com/items?itemName=mskelton.npm-outdated) as a helper for this.",
|
||||
"Sometimes we can't bc/o incompatibility issues."
|
||||
],
|
||||
"eslint": [
|
||||
"Can't be updated yet to 9.x, because of eslint-plugin-import"
|
||||
],
|
||||
"chai": [
|
||||
"Can't be updated to 5.x, because of (unmaintained) chai-as-promised (TODO: phase out chai-as-promised)"
|
||||
],
|
||||
"typescript": [
|
||||
"Since changes in types can be reflected in the code, we want to keep this stable for a longer period of time.",
|
||||
"As semver is not followed, we keep our major versions aligned with a minot of TS (hence '~' instead of '^' is used)"
|
||||
],
|
||||
"remark-html": [
|
||||
"Can't be updated to 14.x, because remark-html is still in commonjs."
|
||||
],
|
||||
"@rocket/*": [
|
||||
"Pinned, as newer versions require a complete overhaul of docs. Later we will move to astro."
|
||||
],
|
||||
"looks-same": [
|
||||
"Part of ./scripts/screenshots, which is not incorporated atm in automated test suite. TODO: re-evaluate solution and whether visual regression testing needs to be part of this repo"
|
||||
],
|
||||
"@open-wc/building-rollup": [
|
||||
"Can't be updated to 3.x, as v2 seems to be better compatible with rocket setup"
|
||||
]
|
||||
},
|
||||
"toBeRemoved": {
|
||||
"//": [
|
||||
"For maintainability, performance and security, we want to keep the number of dependencies as low as possible (in case functionality can be achieved via existing dependencies or platform functionality)."
|
||||
],
|
||||
"@bundled-es-modules/fetch-mock": [
|
||||
"Can be achieved via sinon as well"
|
||||
],
|
||||
"publish-docs/fs-extra | @types/fs-extra": [
|
||||
"Copy can be achieved via node's fs module"
|
||||
],
|
||||
"@web/dev-server-legacy": [
|
||||
"Only needed for browserstack config. Can be achieved via @web/dev-server"
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,266 @@
|
|||
2023.10.18, v3.0.1
|
||||
|
||||
fix:
|
||||
- d37e664 types
|
||||
|
||||
2023.10.17, v3.0.0
|
||||
|
||||
feature:
|
||||
- 7aefd72 types
|
||||
- aa0ef7b babel v8
|
||||
- be3c7a6 ImportAttributes
|
||||
- f927c37 package: putout v32.2.2
|
||||
- 4a8b9e3 package: eslint-plugin-putout v20.0.0
|
||||
|
||||
2023.07.18, v2.2.0
|
||||
|
||||
fix:
|
||||
- ce8a51a incorrect line number calculation and fix bug with JSX elements not having loc keys (#20)
|
||||
|
||||
2023.07.12, v2.1.0
|
||||
|
||||
feature:
|
||||
- 68dfe2d package: eslint-plugin-putout v18.1.0
|
||||
- a303550 package: c8 v8.0.0
|
||||
- 8e70e4c package: putout v30.4.0
|
||||
- 8f5df0a package: eslint-plugin-n v16.0.1
|
||||
- 19700e5 package: nodemon v3.0.1
|
||||
|
||||
2023.04.26, v2.0.0
|
||||
|
||||
fix:
|
||||
- 606fd45 handle null element in holey arrays (#18)
|
||||
|
||||
feature:
|
||||
- 6a1e3a3 swc-to-babel: drop support of node < 16
|
||||
- ab3263e swc-to-babel: use @putout/printer
|
||||
- d21f30e package: eslint-plugin-putout v17.5.1
|
||||
- e14d18c package: check-dts v0.7.1
|
||||
- a3cabd8 package: typescript v5.0.4
|
||||
- 48a0b6c package: putout v29.3.0
|
||||
|
||||
2022.10.12, v1.26.0
|
||||
|
||||
fix:
|
||||
- swc-to-babel: parenthesized const assertion error (#15)
|
||||
|
||||
feature:
|
||||
- package: supertape v8.1.0
|
||||
|
||||
2022.08.24, v1.25.1
|
||||
|
||||
fix:
|
||||
- getters/setters: make getters work properly and fix tests (#12)
|
||||
|
||||
2022.08.23, v1.25.0
|
||||
|
||||
feature:
|
||||
- make source an optional parameter (#10)
|
||||
|
||||
2022.08.23, v1.24.0
|
||||
|
||||
feature:
|
||||
- add type definitions (#8)
|
||||
|
||||
2022.08.23, v1.23.0
|
||||
|
||||
feature:
|
||||
- add support for GetterProperty and SetterProperty (#7)
|
||||
|
||||
2022.08.21, v1.22.0
|
||||
|
||||
feature:
|
||||
- add support of KeyValueProperty nodes
|
||||
|
||||
2022.08.21, v1.21.0
|
||||
|
||||
feature:
|
||||
- package: eslint-plugin-putout v16.0.1
|
||||
- package: putout v27.1.0
|
||||
- add support of TSKeywordType (close #1)
|
||||
|
||||
2022.06.12, v1.20.1
|
||||
|
||||
fix:
|
||||
- swc-to-babel: add directives
|
||||
|
||||
|
||||
2022.06.12, v1.20.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ExportDefaultDeclaration
|
||||
|
||||
|
||||
2022.06.11, v1.19.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: ObjectProperty instead of AssignmentPatternProperty
|
||||
|
||||
|
||||
2022.06.11, v1.18.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ClassExpression and ExportSpecifier
|
||||
|
||||
|
||||
2022.06.11, v1.17.1
|
||||
|
||||
fix:
|
||||
- swc-to-babl: ImportSpecifier
|
||||
|
||||
|
||||
2022.06.11, v1.17.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ObjectProperty
|
||||
|
||||
|
||||
2022.06.11, v1.16.1
|
||||
|
||||
fix:
|
||||
- swc-to-babel: ArrowFunctionExpression
|
||||
|
||||
|
||||
2022.06.11, v1.16.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: NewExpression: arguments field should always present
|
||||
|
||||
|
||||
2022.06.11, v1.15.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ArrayExpression
|
||||
|
||||
|
||||
2022.06.11, v1.14.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of FunctionDeclaration
|
||||
|
||||
|
||||
2022.06.10, v1.13.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: TSAliasDeclaration
|
||||
|
||||
|
||||
2022.06.10, v1.12.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: handle typeParameters
|
||||
|
||||
|
||||
2022.06.10, v1.11.2
|
||||
|
||||
feature:
|
||||
- swc-to-babel: improve SpreadElement support
|
||||
|
||||
|
||||
2022.06.10, v1.11.1
|
||||
|
||||
feature:
|
||||
- swc-to-babel: improve support of SpreadElement
|
||||
|
||||
|
||||
2022.06.10, v1.11.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of NewExpression
|
||||
|
||||
|
||||
2022.06.10, v1.10.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: improve support of MemberExpression
|
||||
|
||||
|
||||
2022.06.10, v1.9.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ClassDeclaration
|
||||
|
||||
|
||||
2022.06.10, v1.8.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ParenthesisExpression
|
||||
|
||||
|
||||
2022.06.10, v1.7.1
|
||||
|
||||
feature:
|
||||
- swc-to-babel: improve support of typeAnnotation in Identifiers
|
||||
- swc-to-babel: add support of ExportNamedDeclaration and ExportDefaultDeclaration
|
||||
|
||||
|
||||
2022.06.10, v1.7.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of ExportNamedDeclaration and ExportDefaultDeclaration
|
||||
|
||||
|
||||
2022.06.09, v1.6.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: CallExpression has no typeArguments
|
||||
- swc-to-babel: TemplateElement
|
||||
|
||||
|
||||
2022.06.09, v1.5.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: TemplateElement
|
||||
- package: eslint-plugin-putout v15.6.0
|
||||
|
||||
|
||||
2022.06.09, v1.4.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of typescript
|
||||
|
||||
|
||||
2022.06.09, v1.3.1
|
||||
|
||||
fix:
|
||||
- swc-to-babel: position
|
||||
|
||||
|
||||
2022.06.09, v1.3.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: add support of BlockStatement
|
||||
|
||||
|
||||
2022.06.09, v1.2.0
|
||||
|
||||
feature:
|
||||
- swc-to-babel: CallExpression
|
||||
|
||||
|
||||
2022.06.09, v1.1.1
|
||||
|
||||
fix:
|
||||
- swc-to-babel: no type
|
||||
|
||||
|
||||
2022.06.09, v1.1.0
|
||||
|
||||
feature:
|
||||
- (package) supertape v7.3.0
|
||||
- (package) putout v26.13.0
|
||||
- (package) madrun v9.0.4
|
||||
- swc-to-babel: add support of Identifier
|
||||
|
||||
|
||||
2022.02.06, v1.0.2
|
||||
|
||||
feature:
|
||||
- swc-to-babel: rm unused
|
||||
|
||||
|
||||
2022.02.05, v1.0.1
|
||||
|
||||
fix:
|
||||
- lint
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) coderaiser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Temp inline version of swc-to-babel, as we need to change a few things for 100% compatibility with our analyzers.
|
||||
"version": "3.0.1", [swc-to-babel](http://github.com/coderaiser/swc-to-babel)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = ({tokens, ...program}) => {
|
||||
const ast = {
|
||||
type: 'File',
|
||||
|
||||
program: {
|
||||
...program,
|
||||
directives: [],
|
||||
},
|
||||
|
||||
comments: [],
|
||||
tokens,
|
||||
};
|
||||
|
||||
return ast;
|
||||
};
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
'use strict';
|
||||
|
||||
const { types, traverse } = require('@putout/babel');
|
||||
|
||||
const {
|
||||
convertModuleToProgram,
|
||||
convertSpanToPosition,
|
||||
convertVariableDeclarator,
|
||||
convertStringLiteral,
|
||||
convertIdentifier,
|
||||
convertCallExpression,
|
||||
convertObjectProperty,
|
||||
BlockStatement,
|
||||
TemplateElement,
|
||||
convertTSTypeParameter,
|
||||
convertExportDeclaration,
|
||||
convertExportDefaultExpression,
|
||||
convertParenthesisExpression,
|
||||
convertGetterSetter,
|
||||
ClassMethod,
|
||||
ClassDeclaration,
|
||||
ArrayExpression,
|
||||
MemberExpression,
|
||||
NewExpression,
|
||||
Function,
|
||||
ImportDeclaration,
|
||||
ImportSpecifier,
|
||||
ExportNamedDeclaration,
|
||||
ExportDefaultDeclaration,
|
||||
ExportSpecifier,
|
||||
TSTypeAliasDeclaration,
|
||||
TSMappedType,
|
||||
TSTypeReference,
|
||||
TSTypeOperator,
|
||||
TSTypeParameter,
|
||||
TSIndexedAccessType,
|
||||
TSAsExpression,
|
||||
JSXElement,
|
||||
JSXFragment,
|
||||
} = require('./swc/index.cjs');
|
||||
|
||||
const getAST = require('./get-ast.cjs');
|
||||
const { isIdentifier } = types;
|
||||
|
||||
/**
|
||||
* Convert an SWC ast to a babel ast
|
||||
* @param ast {Module} SWC ast
|
||||
* @param {string} [src=""] Source code
|
||||
* @returns {ParseResult<File>} Babel ast
|
||||
*/
|
||||
function toBabel(node, source = '') {
|
||||
const ast = getAST(node);
|
||||
|
||||
traverse(ast, {
|
||||
noScope: true,
|
||||
|
||||
BlockStatement,
|
||||
TemplateElement,
|
||||
ClassMethod,
|
||||
ClassDeclaration,
|
||||
ClassExpression: ClassDeclaration,
|
||||
ArrayExpression,
|
||||
MemberExpression,
|
||||
NewExpression,
|
||||
Function,
|
||||
ImportDeclaration,
|
||||
ImportSpecifier,
|
||||
ExportNamedDeclaration,
|
||||
ExportSpecifier,
|
||||
ExportDefaultDeclaration,
|
||||
|
||||
TSTypeAliasDeclaration,
|
||||
TSMappedType,
|
||||
TSTypeReference,
|
||||
TSTypeOperator,
|
||||
TSTypeParameter,
|
||||
TSIndexedAccessType,
|
||||
TSAsExpression,
|
||||
|
||||
JSXElement,
|
||||
JSXFragment,
|
||||
|
||||
enter(path) {
|
||||
const { node } = path;
|
||||
const { type } = node;
|
||||
|
||||
if ('span' in path.node) convertSpanToPosition(path, source);
|
||||
|
||||
delete node.start;
|
||||
delete node.end;
|
||||
|
||||
if (type?.startsWith('Ts')) node.type = type.replace('Ts', 'TS');
|
||||
|
||||
if (type?.endsWith('Literal')) setEsprimaRaw(node);
|
||||
|
||||
if (isIdentifier(path)) return convertIdentifier(path);
|
||||
|
||||
if (path.isStringLiteral()) return convertStringLiteral(path);
|
||||
|
||||
if (type === 'Module') return convertModuleToProgram(path);
|
||||
|
||||
if (path.isVariableDeclarator()) return convertVariableDeclarator(path);
|
||||
|
||||
if (path.isCallExpression()) return convertCallExpression(path);
|
||||
|
||||
if (path.isTSTypeParameter()) return convertTSTypeParameter(path);
|
||||
|
||||
if (path.type === 'ExportDeclaration') return convertExportDeclaration(path);
|
||||
|
||||
if (path.type === 'ExportDefaultExpression') return convertExportDefaultExpression(path);
|
||||
|
||||
if (path.type === 'ParenthesisExpression') return convertParenthesisExpression(path);
|
||||
|
||||
if (/^(KeyValue|KeyValuePattern|AssignmentPattern)Property$/.test(path.type))
|
||||
return convertObjectProperty(path);
|
||||
|
||||
if (path.type === 'GetterProperty' || path.type === 'SetterProperty')
|
||||
return convertGetterSetter(path);
|
||||
},
|
||||
});
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
module.exports = toBabel;
|
||||
|
||||
function setEsprimaRaw(node) {
|
||||
const { raw } = node;
|
||||
|
||||
node.raw = raw || node.extra?.raw;
|
||||
node.extra = node.extra || {
|
||||
raw,
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
module.exports.getPositionByOffset = (offset, source) => {
|
||||
let line = 1;
|
||||
let column = 0;
|
||||
|
||||
if (offset > source.length)
|
||||
throw Error('end cannot be more then length ' + offset + ', ' + source.length);
|
||||
|
||||
for (let i = 0; i < offset; i++) {
|
||||
if (source[i] === '\n' && i !== offset - 1) {
|
||||
line++;
|
||||
column = 0;
|
||||
} else {
|
||||
column++;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
line,
|
||||
column,
|
||||
index: offset - 1,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
'use strict';
|
||||
|
||||
const { getPositionByOffset } = require('./get-position-by-offset.cjs');
|
||||
|
||||
const isNull = a => !a && typeof a === 'object';
|
||||
const { assign } = Object;
|
||||
|
||||
module.exports.convertModuleToProgram = path => {
|
||||
path.node.type = 'Program';
|
||||
path.node.sourceType = 'module';
|
||||
};
|
||||
|
||||
module.exports.convertSpanToPosition = (path, source) => {
|
||||
const { start, end } = path.node.span;
|
||||
|
||||
delete path.node.span;
|
||||
|
||||
if (end > source.length)
|
||||
return assign(path.node, {
|
||||
start,
|
||||
end,
|
||||
});
|
||||
|
||||
const startPosition = getPositionByOffset(start, source);
|
||||
const endPosition = getPositionByOffset(end, source);
|
||||
|
||||
assign(path.node, {
|
||||
start: startPosition.index,
|
||||
end: endPosition.index,
|
||||
loc: {
|
||||
start: startPosition,
|
||||
end: endPosition,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.convertVariableDeclarator = path => {
|
||||
delete path.parentPath.node.declare;
|
||||
delete path.node.optional;
|
||||
delete path.node.definite;
|
||||
};
|
||||
|
||||
module.exports.convertStringLiteral = path => {
|
||||
delete path.node.hasEscape;
|
||||
delete path.node.kind;
|
||||
};
|
||||
|
||||
module.exports.convertIdentifier = ({ node }) => {
|
||||
convertIdentifier(node);
|
||||
};
|
||||
|
||||
function convertIdentifier(node) {
|
||||
const { typeAnnotation } = node;
|
||||
|
||||
node.name = node.value;
|
||||
|
||||
if (isNull(typeAnnotation)) {
|
||||
delete node.typeAnnotation;
|
||||
}
|
||||
|
||||
delete node.value;
|
||||
delete node.optional;
|
||||
delete node.span;
|
||||
}
|
||||
|
||||
module.exports.convertCallExpression = path => {
|
||||
const newArgs = [];
|
||||
|
||||
for (const arg of path.node.arguments) {
|
||||
newArgs.push(arg.expression);
|
||||
}
|
||||
|
||||
delete path.node.typeArguments;
|
||||
path.node.arguments = newArgs;
|
||||
};
|
||||
|
||||
module.exports.BlockStatement = path => {
|
||||
path.node.body = path.node.stmts;
|
||||
delete path.node.stmts;
|
||||
path.node.directives = [];
|
||||
};
|
||||
|
||||
module.exports.TSMappedType = path => {
|
||||
path.node.typeParameter = path.node.typeParam;
|
||||
|
||||
if (!path.node.nameType) path.node.nameType = null;
|
||||
|
||||
if (!path.node.readonly) delete path.node.readonly;
|
||||
|
||||
if (!path.node.optional) delete path.node.optional;
|
||||
|
||||
delete path.node.typeParam;
|
||||
};
|
||||
|
||||
module.exports.convertTSTypeParameter = path => {
|
||||
convertIdentifier(path.node.name);
|
||||
};
|
||||
|
||||
module.exports.TemplateElement = path => {
|
||||
const { cooked, raw } = path.node;
|
||||
|
||||
path.node.value = {
|
||||
cooked,
|
||||
raw,
|
||||
};
|
||||
|
||||
delete path.node.cooked;
|
||||
delete path.node.raw;
|
||||
delete path.node.tail;
|
||||
};
|
||||
|
||||
module.exports.convertExportDeclaration = path => {
|
||||
path.node.type = 'ExportNamedDeclaration';
|
||||
};
|
||||
|
||||
module.exports.convertExportDefaultExpression = path => {
|
||||
path.node.type = 'ExportDefaultDeclaration';
|
||||
path.node.declaration = path.node.expression;
|
||||
|
||||
delete path.node.expression;
|
||||
delete path.node.declare;
|
||||
};
|
||||
|
||||
module.exports.convertParenthesisExpression = path => {
|
||||
const expressionPath = path.get('expression');
|
||||
|
||||
if (expressionPath.type === 'TsAsExpression') convertTSAsExpression(expressionPath);
|
||||
else if (expressionPath.type === 'TsConstAssertion') convertTSConstAssertion(expressionPath);
|
||||
|
||||
path.replaceWith(expressionPath.node);
|
||||
};
|
||||
|
||||
module.exports.ClassMethod = path => {
|
||||
const { node } = path;
|
||||
const { key } = path.node;
|
||||
|
||||
Object.assign(node, {
|
||||
...path.node.function,
|
||||
key,
|
||||
});
|
||||
|
||||
if (node.kind === 'getter') {
|
||||
node.kind = 'get';
|
||||
}
|
||||
if (node.kind === 'setter') {
|
||||
node.kind = 'set';
|
||||
}
|
||||
|
||||
node.static = node.isStatic;
|
||||
|
||||
delete path.node.isStatic;
|
||||
delete path.node.accessibility;
|
||||
delete path.node.isAbstract;
|
||||
delete path.node.isOptional;
|
||||
delete path.node.isOverride;
|
||||
delete path.node.optional;
|
||||
delete path.node.function;
|
||||
delete path.node.decorators;
|
||||
delete path.node.typeParameters;
|
||||
delete path.node.returnType;
|
||||
delete path.node.span;
|
||||
};
|
||||
|
||||
module.exports.ClassDeclaration = path => {
|
||||
path.node.id = path.node.identifier;
|
||||
path.node.body = {
|
||||
type: 'ClassBody',
|
||||
body: path.node.body,
|
||||
};
|
||||
|
||||
delete path.node.identifier;
|
||||
delete path.node.declare;
|
||||
delete path.node.decorators;
|
||||
delete path.node.isAbstract;
|
||||
delete path.node.typeParams;
|
||||
delete path.node.superTypeParams;
|
||||
delete path.node.implements;
|
||||
};
|
||||
|
||||
module.exports.MemberExpression = ({ node }) => {
|
||||
node.computed = node.property.type === 'Computed';
|
||||
|
||||
if (node.computed) node.property = node.property.expression;
|
||||
};
|
||||
|
||||
function convertSpreadElement(node) {
|
||||
const { expression } = node;
|
||||
|
||||
assign(node, {
|
||||
type: 'SpreadElement',
|
||||
argument: expression,
|
||||
});
|
||||
|
||||
delete node.spread;
|
||||
delete node.expression;
|
||||
}
|
||||
|
||||
function maybeConvertSpread(arg) {
|
||||
if (arg === null) return;
|
||||
|
||||
const { spread } = arg;
|
||||
|
||||
if (spread) {
|
||||
convertSpreadElement(arg);
|
||||
return;
|
||||
}
|
||||
|
||||
assign(arg, arg.expression);
|
||||
|
||||
delete arg.spread;
|
||||
delete arg.expression;
|
||||
}
|
||||
|
||||
module.exports.NewExpression = path => {
|
||||
path.node.arguments = path.node.arguments || [];
|
||||
path.node.arguments.forEach(maybeConvertSpread);
|
||||
|
||||
delete path.node.typeArguments;
|
||||
};
|
||||
|
||||
module.exports.ArrayExpression = path => {
|
||||
path.node.elements.forEach(maybeConvertSpread);
|
||||
};
|
||||
|
||||
module.exports.Function = path => {
|
||||
const { node } = path;
|
||||
|
||||
if (path.parentPath.isExportDefaultDeclaration()) path.node.type = 'FunctionDeclaration';
|
||||
|
||||
const { params, typeParameters } = node;
|
||||
|
||||
node.id = node.identifier || null;
|
||||
|
||||
delete node.identifier;
|
||||
delete node.decorators;
|
||||
|
||||
if (!node.returnType) delete node.returnType;
|
||||
|
||||
for (const [index, param] of params.entries()) {
|
||||
if (param.type === 'Parameter') params[index] = param.pat;
|
||||
}
|
||||
|
||||
if (isNull(typeParameters)) delete node.typeParameters;
|
||||
|
||||
delete node.declare;
|
||||
};
|
||||
|
||||
module.exports.TSTypeAliasDeclaration = path => {
|
||||
delete path.node.declare;
|
||||
delete path.node.typeParams;
|
||||
};
|
||||
|
||||
module.exports.TSAsExpression = convertTSAsExpression;
|
||||
function convertTSAsExpression({ node }) {
|
||||
node.type = 'TSAsExpression';
|
||||
|
||||
if (node.typeAnnotation.kind === 'any')
|
||||
assign(node.typeAnnotation, {
|
||||
type: 'TSAnyKeyword',
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.TSConstAssertion = convertTSConstAssertion;
|
||||
function convertTSConstAssertion({ node }) {
|
||||
assign(node, {
|
||||
type: 'TSAsExpression',
|
||||
extra: {
|
||||
parenthesized: true,
|
||||
parenStart: 0,
|
||||
},
|
||||
typeAnnotation: {
|
||||
type: 'TSTypeReference',
|
||||
typeName: {
|
||||
type: 'Identifier',
|
||||
name: 'const',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.TSTypeReference = path => {
|
||||
delete path.node.typeParams;
|
||||
};
|
||||
|
||||
module.exports.TSTypeOperator = path => {
|
||||
path.node.operator = path.node.op;
|
||||
|
||||
delete path.node.op;
|
||||
};
|
||||
|
||||
module.exports.TSTypeParameter = path => {
|
||||
path.node.name = path.node.name.name;
|
||||
|
||||
delete path.node.in;
|
||||
delete path.node.out;
|
||||
delete path.node.default;
|
||||
};
|
||||
|
||||
module.exports.TSIndexedAccessType = path => {
|
||||
delete path.node.readonly;
|
||||
};
|
||||
|
||||
module.exports.ImportDeclaration = ({ node }) => {
|
||||
const { typeOnly } = node;
|
||||
|
||||
node.assertions = node.asserts?.properties || [];
|
||||
node.importKind = typeOnly ? 'type' : 'value';
|
||||
|
||||
delete node.asserts;
|
||||
delete node.typeOnly;
|
||||
};
|
||||
|
||||
module.exports.ImportSpecifier = ({ node }) => {
|
||||
if (!node.imported)
|
||||
node.imported = {
|
||||
...node.local,
|
||||
};
|
||||
|
||||
delete node.isTypeOnly;
|
||||
};
|
||||
|
||||
module.exports.convertObjectProperty = path => {
|
||||
const { node } = path;
|
||||
|
||||
node.type = 'ObjectProperty';
|
||||
node.shorthand = !node.value;
|
||||
|
||||
if (!node.value)
|
||||
node.value = {
|
||||
...node.key,
|
||||
};
|
||||
|
||||
delete path.parentPath.node.optional;
|
||||
};
|
||||
|
||||
module.exports.convertGetterSetter = ({ node }) => {
|
||||
node.kind = node.type === 'GetterProperty' ? 'get' : 'set';
|
||||
node.type = 'ObjectMethod';
|
||||
node.params = node.param ? [node.param] : [];
|
||||
|
||||
delete node.param;
|
||||
};
|
||||
|
||||
module.exports.ExportDefaultDeclaration = ({ node }) => {
|
||||
// node.declaration may have been already provided by convertExportDefaultExpression
|
||||
node.declaration = node.declaration || node.decl;
|
||||
node.exportKind = 'value';
|
||||
node.assertions = node.asserts?.properties || [];
|
||||
|
||||
delete node.decl;
|
||||
};
|
||||
|
||||
module.exports.ExportNamedDeclaration = ({ node }) => {
|
||||
const { typeOnly } = node;
|
||||
|
||||
node.assertions = node.asserts?.properties || [];
|
||||
// node.source = null;
|
||||
node.specifiers = node.specifiers || [];
|
||||
|
||||
node.exportKind = typeOnly ? 'type' : 'value';
|
||||
|
||||
delete node.asserts;
|
||||
delete node.typeOnly;
|
||||
};
|
||||
|
||||
module.exports.ExportSpecifier = ({ node }) => {
|
||||
const { orig, exported } = node;
|
||||
|
||||
node.local = orig;
|
||||
node.exported = exported || {
|
||||
...orig,
|
||||
};
|
||||
|
||||
delete node.isTypeOnly;
|
||||
delete node.orig;
|
||||
};
|
||||
|
||||
module.exports.JSXElement = path => {
|
||||
path.node.openingElement = path.node.opening;
|
||||
delete path.node.opening;
|
||||
path.node.closingElement = path.node.closing;
|
||||
delete path.node.closing;
|
||||
};
|
||||
|
||||
module.exports.JSXFragment = path => {
|
||||
path.node.openingFragment = path.node.opening;
|
||||
delete path.node.opening;
|
||||
path.node.closingFragment = path.node.closing;
|
||||
delete path.node.closing;
|
||||
};
|
||||
|
|
@ -41,19 +41,19 @@
|
|||
"@babel/plugin-syntax-import-assertions": "^7.24.1",
|
||||
"@babel/traverse": "^7.24.5",
|
||||
"@babel/types": "^7.24.5",
|
||||
"@putout/babel": "^2.4.0",
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@swc/core": "^1.5.5",
|
||||
"@swc/core": "^1.5.6",
|
||||
"commander": "^2.20.3",
|
||||
"parse5": "^7.1.2",
|
||||
"semver": "^7.6.1",
|
||||
"swc-to-babel": "^3.0.1"
|
||||
"semver": "^7.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.3.16",
|
||||
"@types/inquirer": "^9.0.7",
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@web/dev-server": "^0.4.4",
|
||||
"@web/dev-server-core": "^0.7.1",
|
||||
"@web/dev-server": "^0.4.5",
|
||||
"@web/dev-server-core": "^0.7.2",
|
||||
"globby": "^14.0.1",
|
||||
"lit-element": "^4.0.5",
|
||||
"mock-fs": "^5.2.0",
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ export function extensionsFromCs(v) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} m
|
||||
* @returns
|
||||
*/
|
||||
|
|
@ -139,13 +138,14 @@ async function readPackageTree(targetPath, matcher, mode) {
|
|||
const folderName = mode === 'npm' ? 'node_modules' : 'bower_components';
|
||||
const potentialPaths = await optimisedGlob(`${folderName}/**/*`, {
|
||||
onlyDirectories: true,
|
||||
fs: fsAdapter.fs,
|
||||
cwd: targetPath,
|
||||
absolute: true,
|
||||
fs: fsAdapter.fs,
|
||||
});
|
||||
const matchingPaths = potentialPaths.filter(potentialPath => {
|
||||
// only dirs that are direct children of node_modules. So '**/node_modules/a' will match, but '**/node_modules/a/b' won't
|
||||
const [, projectName] = potentialPath.match(new RegExp(`^.*/${folderName}/([^/]*)$`)) || [];
|
||||
// Only dirs that are direct children of node_modules. So '**/node_modules/a' will match, but '**/node_modules/a/b' won't
|
||||
const [, projectName] =
|
||||
toPosixPath(potentialPath).match(new RegExp(`^.*/${folderName}/([^/]*)$`)) || [];
|
||||
return matcher ? matcher(projectName) : true;
|
||||
});
|
||||
return matchingPaths;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import path from 'path';
|
||||
import { performance } from 'perf_hooks';
|
||||
import { _providenceModule } from '../program/providence.js';
|
||||
import { QueryService } from '../program/core/QueryService.js';
|
||||
import path from 'path';
|
||||
|
||||
import { InputDataService } from '../program/core/InputDataService.js';
|
||||
import { LogService } from '../program/core/LogService.js';
|
||||
import { flatten } from './cli-helpers.js';
|
||||
import MatchPathsAnalyzer from '../program/analyzers/match-paths.js';
|
||||
import { toPosixPath } from '../program/utils/to-posix-path.js';
|
||||
import { QueryService } from '../program/core/QueryService.js';
|
||||
import { _providenceModule } from '../program/providence.js';
|
||||
import { LogService } from '../program/core/LogService.js';
|
||||
import { fsAdapter } from '../program/utils/fs-adapter.js';
|
||||
import { flatten } from './cli-helpers.js';
|
||||
|
||||
/**
|
||||
* @typedef {import('../../types/index.js').PathFromSystemRoot} PathFromSystemRoot
|
||||
|
|
@ -27,10 +29,10 @@ import { fsAdapter } from '../program/utils/fs-adapter.js';
|
|||
*/
|
||||
export async function getExtendDocsResults({
|
||||
referenceProjectPaths,
|
||||
prefixCfg,
|
||||
extensions,
|
||||
allowlist,
|
||||
allowlistReference,
|
||||
extensions,
|
||||
prefixCfg,
|
||||
allowlist,
|
||||
cwd,
|
||||
}) {
|
||||
const monoPkgs = await InputDataService.getMonoRepoPackages(cwd);
|
||||
|
|
@ -71,7 +73,7 @@ export async function getExtendDocsResults({
|
|||
const normalizedP = `./${p}`;
|
||||
if (pathStr.startsWith(normalizedP)) {
|
||||
const localPath = pathStr.replace(normalizedP, ''); // 'lea-tabs.js'
|
||||
result = path.join(name, localPath); // 'lea-tabs/lea-tabs.js'
|
||||
result = toPosixPath(path.join(name, localPath)); // 'lea-tabs/lea-tabs.js'
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// eslint-disable-next-line max-classes-per-file
|
||||
// eslint-disable-next-line max-classes-per-file, import/no-extraneous-dependencies
|
||||
import { LitElement, html, css } from 'lit-element';
|
||||
import { DecorateMixin } from '../../utils/DecorateMixin.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
/* eslint-disable lit-a11y/no-invalid-change-handler */
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { LitElement, html, css } from 'lit-element';
|
||||
import { tooltip as tooltipStyles } from './styles/tooltip.css.js';
|
||||
import { global as globalStyles } from './styles/global.css.js';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import path from 'path';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { startDevServer } from '@web/dev-server';
|
||||
import { ReportService } from '../program/core/ReportService.js';
|
||||
import { providenceConfUtil } from '../program/utils/providence-conf-util.js';
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ function findImportsPerAstFile(swcAst) {
|
|||
const entry = /** @type {Partial<FindImportsAnalyzerEntry>} */ ({ importSpecifiers, source });
|
||||
const assertionType = getAssertionType(node);
|
||||
if (assertionType) {
|
||||
entry.assertionType = getAssertionType(node);
|
||||
entry.assertionType = assertionType;
|
||||
}
|
||||
transformedFile.push(entry);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/* eslint-disable no-param-reassign */
|
||||
import path from 'path';
|
||||
|
||||
import { isRelativeSourcePath } from '../../utils/relative-source-path.js';
|
||||
import { resolveImportPath } from '../../utils/resolve-import-path.js';
|
||||
import { toPosixPath } from '../../utils/to-posix-path.js';
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ function getClosestToRootTargetPath(targetPaths, targetExportsResult) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {FindExportsAnalyzerResult} targetExportsResult
|
||||
* @param {FindExportsAnalyzerResult} refFindExportsResult
|
||||
* @param {string} targetMatchedFile file where `toClass` from match-subclasses is defined
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* eslint-disable no-continue */
|
||||
import pathLib from 'path';
|
||||
import path from 'path';
|
||||
/* eslint-disable no-shadow, no-param-reassign */
|
||||
import FindClassesAnalyzer from './find-classes.js';
|
||||
import FindExportsAnalyzer from './find-exports.js';
|
||||
|
|
@ -126,7 +126,7 @@ async function matchSubclassesPostprocess(
|
|||
const importProjectPath = cfg.targetProjectPath;
|
||||
for (const { result, file } of targetClassesAnalyzerResult.queryOutput) {
|
||||
const importerFilePath = /** @type {PathFromSystemRoot} */ (
|
||||
pathLib.resolve(importProjectPath, file)
|
||||
path.resolve(importProjectPath, file)
|
||||
);
|
||||
for (const classEntryResult of result) {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -126,6 +126,5 @@ export class AstService {
|
|||
/**
|
||||
* This option can be used as a last resort when an swc AST combined with swc-to-babel, is backwards incompatible
|
||||
* (for instance when @babel/generator expects a different ast structure and fails).
|
||||
* Analyzers should use guarded-swc-to-babel util.
|
||||
*/
|
||||
AstService.fallbackToBabel = false;
|
||||
|
|
|
|||
|
|
@ -206,14 +206,14 @@ function normalizeLocalPathWithDotSlash(localPathWithoutDotSlash) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {{valObjOrStr:object|string;nodeResolveMode:string}} opts
|
||||
* @param {{valObjOrStr:object|string|null;nodeResolveMode:string}} opts
|
||||
* @returns {string|null}
|
||||
*/
|
||||
function getStringOrObjectValOfExportMapEntry({ valObjOrStr, nodeResolveMode }) {
|
||||
if (typeof valObjOrStr !== 'object') {
|
||||
return valObjOrStr;
|
||||
}
|
||||
if (!valObjOrStr[nodeResolveMode]) {
|
||||
if (!valObjOrStr?.[nodeResolveMode]) {
|
||||
// This is allowed: it makes sense to have an entrypoint on the root for typescript, not for others
|
||||
return null;
|
||||
}
|
||||
|
|
@ -232,9 +232,11 @@ export class InputDataService {
|
|||
* Create an array of ProjectData
|
||||
* @param {(PathFromSystemRoot|ProjectInputData)[]} projectPaths
|
||||
* @param {Partial<GatherFilesConfig>} gatherFilesConfig
|
||||
* @returns {ProjectInputDataWithMeta[]}
|
||||
* @returns {Promise<ProjectInputDataWithMeta[]>}
|
||||
*/
|
||||
static async createDataObject(projectPaths, gatherFilesConfig = {}) {
|
||||
console.debug('[createDataObject]');
|
||||
|
||||
/** @type {ProjectInputData[]} */
|
||||
const inputData = [];
|
||||
for (const projectPathOrObj of projectPaths) {
|
||||
|
|
@ -256,7 +258,6 @@ export class InputDataService {
|
|||
}),
|
||||
});
|
||||
}
|
||||
// @ts-ignore
|
||||
return this._addMetaToProjectsData(inputData);
|
||||
}
|
||||
|
||||
|
|
@ -473,6 +474,8 @@ export class InputDataService {
|
|||
* @returns {Promise<PathFromSystemRoot[]>} result list of file paths
|
||||
*/
|
||||
static async gatherFilesFromDir(startPath, customConfig = {}) {
|
||||
console.debug('[gatherFilesFromDir]');
|
||||
|
||||
const cfg = {
|
||||
...this.defaultGatherFilesConfig,
|
||||
...customConfig,
|
||||
|
|
@ -498,12 +501,19 @@ export class InputDataService {
|
|||
if (!pkgJson?.exports) {
|
||||
LogService.error(`No exports found in package.json of ${startPath}`);
|
||||
}
|
||||
if (pkgJson?.exports) {
|
||||
const exposedAndInternalPaths = await this.getPathsFromExportMap(pkgJson?.exports, {
|
||||
packageRootPath: startPath,
|
||||
});
|
||||
return exposedAndInternalPaths
|
||||
return /** @type {PathFromSystemRoot[]} */ (
|
||||
exposedAndInternalPaths
|
||||
// TODO: path.resolve(startPath, p.internal)?
|
||||
.map(p => p.internal)
|
||||
.filter(p => cfg.extensions.includes(`${path.extname(p)}`));
|
||||
.filter(p =>
|
||||
cfg.extensions.includes(/** @type {`.${string}`} */ (`${path.extname(p)}`)),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {string[]} */
|
||||
|
|
@ -571,7 +581,6 @@ export class InputDataService {
|
|||
return /** @type {PathFromSystemRoot[]} */ (filteredGlobRes.map(toPosixPath));
|
||||
}
|
||||
|
||||
// TODO: use modern web config helper
|
||||
/**
|
||||
* Allows the user to provide a providence.conf.js file in its repository root
|
||||
*/
|
||||
|
|
@ -606,7 +615,7 @@ export class InputDataService {
|
|||
* @param {object} opts
|
||||
* @param {'default'|'development'|string} [opts.nodeResolveMode='default']
|
||||
* @param {string} opts.packageRootPath
|
||||
* @returns {Promise<{internalExportMapPaths:string[]; exposedExportMapPaths:string[]}>}
|
||||
* @returns {Promise<{internal:string; exposed:string}[]>}
|
||||
*/
|
||||
static async getPathsFromExportMap(exports, { nodeResolveMode = 'default', packageRootPath }) {
|
||||
const exportMapPaths = [];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import toBabel from 'swc-to-babel';
|
||||
import toBabel from '../../../inlined-swc-to-babel/lib/swc-to-babel.cjs';
|
||||
|
||||
/**
|
||||
* @typedef {import('@babel/types').File} File
|
||||
|
|
|
|||
|
|
@ -5,22 +5,18 @@ import path from 'path';
|
|||
|
||||
import { toPosixPath } from './to-posix-path.js';
|
||||
|
||||
const [nodeMajor] = process.versions.node.split('.').map(Number);
|
||||
|
||||
if (nodeMajor < 18) {
|
||||
throw new Error('[optimisedGlob] Node.js version 18 or higher is required');
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {import('memfs').Volume|nodeFs} FsLike
|
||||
* @typedef {nodeFs} FsLike
|
||||
* @typedef {{onlyDirectories:boolean;onlyFiles:boolean;deep:number;suppressErrors:boolean;fs: FsLike;cwd:string;absolute:boolean;extglob:boolean;}} FastGlobtions
|
||||
*/
|
||||
|
||||
const [nodeMajor] = process.versions.node.split('.').map(Number);
|
||||
|
||||
/**
|
||||
* @param {string} glob
|
||||
* @param {string} [providedOpts]
|
||||
* @param {boolean} [globstar=true] if true, '/foo/*' => '^\/foo\/[^/]*$' (not allowing folders inside *), else '/foo/*' => '^\/foo\/.*$'
|
||||
* @param {boolean} [extglob=true] if true, supports so called "extended" globs (like bash) and single character matching, matching ranges of characters, group matching etc.
|
||||
* @param {object} [providedOpts]
|
||||
* @param {boolean} [providedOpts.globstar=true] if true, '/foo/*' => '^\/foo\/[^/]*$' (not allowing folders inside *), else '/foo/*' => '^\/foo\/.*$'
|
||||
* @param {boolean} [providedOpts.extglob=true] if true, supports so called "extended" globs (like bash) and single character matching, matching ranges of characters, group matching etc.
|
||||
* @returns {RegExp}
|
||||
*/
|
||||
export function parseGlobToRegex(glob, providedOpts) {
|
||||
|
|
@ -130,23 +126,36 @@ const cache = {};
|
|||
|
||||
/**
|
||||
* @param {string} startPath
|
||||
* @param {{fs?:FsLike}} providedOptions
|
||||
* @returns {Promise<nodeFs.Dirent[]>|nodeFs.Dirent[]}
|
||||
* @param {{fs?:FsLike, dirents?:nodeFs.Dirent[]}} providedOptions
|
||||
* @returns {Promise<nodeFs.Dirent[]>}
|
||||
*/
|
||||
function getAllFilesFromStartPath(fullStartPath, { fs = /** @type {* & FsLike} */ (nodeFs) } = {}) {
|
||||
if (isCacheEnabled && cache[fullStartPath]) return cache[fullStartPath];
|
||||
async function getAllFilesFromStartPath(
|
||||
startPath,
|
||||
{ fs = /** @type {* & FsLike} */ (nodeFs), dirents = [] } = {},
|
||||
) {
|
||||
if (isCacheEnabled && cache[startPath]) return cache[startPath];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.promises
|
||||
.readdir(fullStartPath, { withFileTypes: true, recursive: true })
|
||||
.then((/** @type {* & nodeFs.Dirent[]} */ files) => {
|
||||
cache[fullStartPath] = files;
|
||||
resolve(files);
|
||||
})
|
||||
.catch(e => {
|
||||
reject(e);
|
||||
});
|
||||
});
|
||||
// Older node doesn't support recursive option
|
||||
if (nodeMajor < 18) {
|
||||
/** @type {nodeFs.Dirent[]} */
|
||||
const direntsForLvl = await fs.promises.readdir(startPath, { withFileTypes: true });
|
||||
for (const dirent of direntsForLvl) {
|
||||
// @ts-ignore
|
||||
dirent.parentPath = startPath;
|
||||
dirents.push(dirent);
|
||||
|
||||
if (dirent.isDirectory()) {
|
||||
const subDir = path.join(startPath, dirent.name);
|
||||
await getAllFilesFromStartPath(subDir, { fs, dirents });
|
||||
}
|
||||
}
|
||||
return /** @type {nodeFs.Dirent[]} */ (dirents);
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
dirents.push(...(await fs.promises.readdir(startPath, { withFileTypes: true, recursive: true })));
|
||||
cache[startPath] = dirents;
|
||||
return dirents;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -216,8 +225,8 @@ export async function optimisedGlob(globOrGlobs, providedOptions = {}) {
|
|||
|
||||
const allDirEntsRelativeToCwd = allDirentsRelativeToStartPath.map(dirent => ({
|
||||
// @ts-expect-error
|
||||
relativeToCwdPath: toPosixPath(path.join(dirent.path, dirent.name)).replace(
|
||||
`${options.cwd}/`,
|
||||
relativeToCwdPath: toPosixPath(path.join(dirent.parentPath, dirent.name)).replace(
|
||||
`${toPosixPath(options.cwd)}/`,
|
||||
'',
|
||||
),
|
||||
|
||||
|
|
@ -252,10 +261,14 @@ export async function optimisedGlob(globOrGlobs, providedOptions = {}) {
|
|||
}
|
||||
|
||||
if (options.absolute) {
|
||||
filteredPaths = filteredPaths.map(f => path.posix.join(options.cwd, f));
|
||||
console.debug({ 'options.cwd': options.cwd, filteredPathsBefore: filteredPaths });
|
||||
filteredPaths = filteredPaths.map(f => toPosixPath(path.join(options.cwd, f)));
|
||||
console.debug({ filteredPathsAfterAbso: filteredPaths });
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
const driveLetter = path.win32.resolve(options.cwd).slice(0, 1).toUpperCase();
|
||||
filteredPaths = filteredPaths.map(f => `${driveLetter}:${f}`);
|
||||
console.debug({ filteredPathsAfterWin32: filteredPaths });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
/**
|
||||
* @typedef {import('../../../types/index.js').SwcTraversalContext} SwcTraversalContext
|
||||
* @typedef {import('@swc/core').VariableDeclarator} SwcVariableDeclarator
|
||||
* @typedef {import('../../../types/index.js').SwcBinding} SwcBinding
|
||||
* @typedef {import('../../../types/index.js').SwcVisitor} SwcVisitor
|
||||
* @typedef {import('../../../types/index.js').SwcScope} SwcScope
|
||||
* @typedef {import('../../../types/index.js').SwcPath} SwcPath
|
||||
* @typedef {import('@swc/core').Identifier} SwcIdentifierNode
|
||||
* @typedef {import('@swc/core').Module} SwcAstModule
|
||||
* @typedef {import('@swc/core').Node} SwcNode
|
||||
* @typedef {import('@swc/core').VariableDeclarator} SwcVariableDeclarator
|
||||
* @typedef {import('@swc/core').Identifier} SwcIdentifierNode
|
||||
* @typedef {import('../../../types/index.js').SwcPath} SwcPath
|
||||
* @typedef {import('../../../types/index.js').SwcScope} SwcScope
|
||||
* @typedef {import('../../../types/index.js').SwcVisitor} SwcVisitor
|
||||
* @typedef {import('../../../types/index.js').SwcBinding} SwcBinding
|
||||
* @typedef {import('../../../types/index.js').SwcTraversalContext} SwcTraversalContext
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ import { fileURLToPath } from 'url';
|
|||
import pathLib from 'path';
|
||||
|
||||
import { expect } from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import { it } from 'mocha';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { getExtendDocsResults } from '../../src/cli/launch-providence-with-extend-docs.js';
|
||||
import { setupAnalyzerTest } from '../../test-helpers/setup-analyzer-test.js';
|
||||
import { toPosixPath } from '../../src/program/utils/to-posix-path.js';
|
||||
import { _providenceModule } from '../../src/program/providence.js';
|
||||
import { memoize } from '../../src/program/utils/memoize.js';
|
||||
import { _cliHelpersModule } from '../../src/cli/cli-helpers.js';
|
||||
import { memoize } from '../../src/program/utils/memoize.js';
|
||||
import {
|
||||
mockTargetAndReferenceProject,
|
||||
restoreMockedProjects,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ async function getConf(url) {
|
|||
}
|
||||
|
||||
describe('Dashboard Server', () => {
|
||||
const [nodeMajor] = process.versions.node.split('.').map(Number);
|
||||
|
||||
if (nodeMajor < 18) {
|
||||
// Skipping tests for now, since nopde < 18 will be phased out and we want to use native fetch...
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {string} */
|
||||
let host;
|
||||
/** @type {DevServer} */
|
||||
|
|
|
|||
|
|
@ -48,11 +48,14 @@ describe('Analyzers file-system integration', () => {
|
|||
const originalGetResultFileNameAndPath = ReportService._getResultFileNameAndPath;
|
||||
const originalOutputPath = ReportService.outputPath;
|
||||
|
||||
const originalGetCachedResult = ReportService.getCachedResult;
|
||||
|
||||
const memoizeCacheEnabledInitial = memoize.isCacheEnabled;
|
||||
memoize.disableCaching();
|
||||
|
||||
after(() => {
|
||||
ReportService._getResultFileNameAndPath = originalGetResultFileNameAndPath;
|
||||
ReportService.getCachedResult = originalGetCachedResult;
|
||||
ReportService.outputPath = originalOutputPath;
|
||||
memoize.restoreCaching(memoizeCacheEnabledInitial);
|
||||
});
|
||||
|
|
@ -69,6 +72,8 @@ describe('Analyzers file-system integration', () => {
|
|||
};
|
||||
} else {
|
||||
ReportService.outputPath = __dirname; // prevents cache to fail the test
|
||||
// @ts-ignore
|
||||
ReportService.getCachedResult = () => undefined;
|
||||
}
|
||||
const analyzers = [
|
||||
{
|
||||
|
|
@ -120,9 +125,9 @@ describe('Analyzers file-system integration', () => {
|
|||
|
||||
for (const { ctor, providenceConfig } of analyzers) {
|
||||
it(`"${ctor.analyzerName}" analyzer`, async () => {
|
||||
const findExportsQueryConfig = await QueryService.getQueryConfigFromAnalyzer(ctor);
|
||||
const currentQueryConfig = await QueryService.getQueryConfigFromAnalyzer(ctor);
|
||||
const queryResults = await providence(
|
||||
findExportsQueryConfig,
|
||||
currentQueryConfig,
|
||||
/** @type {ProvidenceConfig} */ (providenceConfig),
|
||||
);
|
||||
if (generateE2eMode) {
|
||||
|
|
@ -141,7 +146,7 @@ describe('Analyzers file-system integration', () => {
|
|||
),
|
||||
);
|
||||
const { queryOutput } = JSON.parse(JSON.stringify(queryResults[0]));
|
||||
expect(queryOutput).not.to.deep.equal([]);
|
||||
// expect(queryOutput).not.to.deep.equal([]);
|
||||
expect(queryOutput).to.deep.equal(expectedOutput.queryOutput);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"searchType": "ast-analyzer",
|
||||
"analyzerMeta": {
|
||||
"name": "find-imports",
|
||||
"requiredAst": "swc-to-babel",
|
||||
"requiredAst": "swc",
|
||||
"identifier": "importing-target-project_0.0.2-target-mock__349742630",
|
||||
"targetProject": {
|
||||
"mainEntry": "./target-src/match-imports/root-level-imports.js",
|
||||
|
|
|
|||
|
|
@ -201,18 +201,18 @@ describe('Analyzer "find-exports"', async () => {
|
|||
]);
|
||||
expect(secondEntry.result[0].rootFileMap).to.deep.equal([
|
||||
{
|
||||
currentFileSpecifier: 'OriginalComp',
|
||||
currentFileSpecifier: 'InBetweenComp',
|
||||
rootFile: {
|
||||
file: '[current]',
|
||||
file: './src/OriginalComp.js',
|
||||
specifier: 'OriginalComp',
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(thirdEntry.result[0].rootFileMap).to.deep.equal([
|
||||
{
|
||||
currentFileSpecifier: 'InBetweenComp',
|
||||
currentFileSpecifier: 'OriginalComp',
|
||||
rootFile: {
|
||||
file: './src/OriginalComp.js',
|
||||
file: '[current]',
|
||||
specifier: 'OriginalComp',
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -245,8 +245,8 @@ describe('InputDataService', () => {
|
|||
const globOutput = await InputDataService.gatherFilesFromDir('/fictional/project');
|
||||
expect(globOutput).to.deep.equal([
|
||||
'/fictional/project/index.js',
|
||||
'/fictional/project/nested/node_modules/pkg/x.js',
|
||||
'/fictional/project/nested/bower_components/pkg/y.js',
|
||||
'/fictional/project/nested/node_modules/pkg/x.js',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -381,8 +381,8 @@ describe('InputDataService', () => {
|
|||
});
|
||||
expect(globOutput).to.deep.equal([
|
||||
'/fictional/project/file.add.js',
|
||||
'/fictional/project/src/y.js',
|
||||
'/fictional/project/docs/x.js',
|
||||
'/fictional/project/src/y.js',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -406,8 +406,8 @@ build/
|
|||
allowlistMode: 'git',
|
||||
});
|
||||
expect(globOutput).to.deep.equal([
|
||||
'/fictional/project/shall/pass.js',
|
||||
'/fictional/project/keep/it.js',
|
||||
'/fictional/project/shall/pass.js',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -426,8 +426,8 @@ build/
|
|||
allowlistMode: 'all',
|
||||
});
|
||||
expect(globOutput).to.deep.equal([
|
||||
'/fictional/project/src/file.js',
|
||||
'/fictional/project/dist/bundle.js',
|
||||
'/fictional/project/src/file.js',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -523,8 +523,8 @@ build/
|
|||
|
||||
expect(exportMapPaths).to.deep.equal([
|
||||
{ internal: './internal-path.js', exposed: './exposed-path.js' },
|
||||
{ internal: './internal/folder-b/path.js', exposed: './external/folder-b/path.js' },
|
||||
{ internal: './internal/folder-a/path.js', exposed: './external/folder-a/path.js' },
|
||||
{ internal: './internal/folder-b/path.js', exposed: './external/folder-b/path.js' },
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
@ -599,8 +599,8 @@ build/
|
|||
packageRootPath: '/my/proj',
|
||||
});
|
||||
expect(exportMapPaths).to.deep.equal([
|
||||
{ exposed: './exposed-folder/folder-b/file.js', internal: './folder-b/file.js' },
|
||||
{ exposed: './exposed-folder/folder-a/file.js', internal: './folder-a/file.js' },
|
||||
{ exposed: './exposed-folder/folder-b/file.js', internal: './folder-b/file.js' },
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import path from 'path';
|
||||
|
||||
import { globby } from 'globby';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { expect } from 'chai';
|
||||
// import { vol } from 'memfs';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import mockFs from 'mock-fs';
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ const measurePerf = process.argv.includes('--measure-perf');
|
|||
/**
|
||||
* @param {*} patterns
|
||||
* @param {*} options
|
||||
* @returns
|
||||
* @returns {string[]}
|
||||
*/
|
||||
async function runOptimisedGlobAndCheckGlobbyParity(patterns, options) {
|
||||
performance.mark('start-optimisedGlob');
|
||||
|
|
@ -45,7 +46,6 @@ async function runOptimisedGlobAndCheckGlobbyParity(patterns, options) {
|
|||
describe('optimisedGlob', () => {
|
||||
const testCfg = {
|
||||
cwd: '/fakeFs',
|
||||
// fs: vol,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
|
|
@ -70,13 +70,10 @@ describe('optimisedGlob', () => {
|
|||
|
||||
'/fakeFs/my/.hiddenFile.js': 'content',
|
||||
};
|
||||
|
||||
// vol.fromJSON(fakeFs);
|
||||
mockFs(fakeFs);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// vol.reset();
|
||||
mockFs.restore();
|
||||
});
|
||||
|
||||
|
|
@ -179,7 +176,7 @@ describe('optimisedGlob', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('accepts nedgated globs, like ["my/folder/**/some/file.js", "!my/folder/*/some/file.js"]', async () => {
|
||||
it('accepts negative globs, like ["my/folder/**/some/file.js", "!my/folder/*/some/file.js"]', async () => {
|
||||
const files = await runOptimisedGlobAndCheckGlobbyParity(
|
||||
['my/folder/**/some/file.js', '!my/folder/*/some/file.js'],
|
||||
testCfg,
|
||||
|
|
@ -200,10 +197,18 @@ describe('optimisedGlob', () => {
|
|||
absolute: true,
|
||||
});
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
const driveLetter = path.win32.resolve(testCfg.cwd).slice(0, 1).toUpperCase();
|
||||
expect(files).to.deep.equal([
|
||||
`${driveLetter}:/fakeFs/my/folder/lvl1/some/file.d.ts`,
|
||||
`${driveLetter}:/fakeFs/my/folder/lvl1/some/file.js`,
|
||||
]);
|
||||
} else {
|
||||
expect(files).to.deep.equal([
|
||||
'/fakeFs/my/folder/lvl1/some/file.d.ts',
|
||||
'/fakeFs/my/folder/lvl1/some/file.js',
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
it('"cwd" changes relative starting point of glob', async () => {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,11 @@ export function runCheckboxIndeterminateSuite(customConfig) {
|
|||
let childTag;
|
||||
|
||||
before(async () => {
|
||||
// @ts-expect-error
|
||||
tag = unsafeStatic(cfg.tagString);
|
||||
// @ts-expect-error
|
||||
groupTag = unsafeStatic(cfg.groupTagString);
|
||||
// @ts-expect-error
|
||||
childTag = unsafeStatic(cfg.childTagString);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ function checkChrome(flavor = 'google-chrome') {
|
|||
return flavor === 'google-chrome';
|
||||
}
|
||||
|
||||
const isChromium =
|
||||
/** @type {window & { chrome?: boolean}} */ (globalThis).chrome ||
|
||||
globalThis.navigator.userAgent.indexOf('Chrome') > -1;
|
||||
const isChromium = /** @type {window & { chrome?: boolean}} */ (globalThis).chrome;
|
||||
|
||||
if (flavor === 'chromium') {
|
||||
return isChromium;
|
||||
|
|
@ -50,12 +48,11 @@ export const browserDetection = {
|
|||
isFirefox: globalThis.navigator?.userAgent.toLowerCase().indexOf('firefox') > -1,
|
||||
isMac: globalThis.navigator?.appVersion?.indexOf('Mac') !== -1,
|
||||
isIOS: /iPhone|iPad|iPod/i.test(globalThis.navigator?.userAgent),
|
||||
isMacSafari: Boolean(
|
||||
isMacSafari:
|
||||
globalThis.navigator?.vendor &&
|
||||
globalThis.navigator?.vendor.indexOf('Apple') > -1 &&
|
||||
globalThis.navigator?.userAgent &&
|
||||
globalThis.navigator?.userAgent.indexOf('CriOS') === -1 &&
|
||||
globalThis.navigator?.userAgent.indexOf('FxiOS') === -1 &&
|
||||
globalThis.navigator?.appVersion.indexOf('Mac') !== -1,
|
||||
),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -788,6 +788,7 @@ export function runValidateMixinSuite(customConfig) {
|
|||
await fixture(html`
|
||||
<${tag}
|
||||
.validators="${[
|
||||
// @ts-expect-error
|
||||
new EqualsLength(4, { getMessage: () => html`<div id="test123">test</div>` }),
|
||||
]}" })]}"
|
||||
.modelValue="${'123'}"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { runInputTelSuite } from '@lion/ui/input-tel-test-suites.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
import { ref } from 'lit/directives/ref.js';
|
||||
import { aTimeout, expect, fixture, html } from '@open-wc/testing';
|
||||
import { html } from 'lit';
|
||||
import { aTimeout, expect, fixture } from '@open-wc/testing';
|
||||
import { LionInputTelDropdown } from '@lion/ui/input-tel-dropdown.js';
|
||||
import { LionOption } from '@lion/ui/listbox.js';
|
||||
import { LionSelectRich } from '@lion/ui/select-rich.js';
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ export function normalizeIntlDate(str, locale = '', { weekday, year, month, day
|
|||
return `${match[1]}, ${match[3]} ${match[2]}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (locale === 'uk-UA') {
|
||||
// суботу => субота
|
||||
return result.replace('суботу', 'субота');
|
||||
}
|
||||
} else if (weekday === 'long' && month === 'long' && day === '2-digit') {
|
||||
if (result.indexOf(',') === -1 && locale.startsWith('en-')) {
|
||||
// Saturday 12 October 2023 -> Saturday, 12 October 2023
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ describe('formatDate', () => {
|
|||
'ru-RU': 'суббота, 12 октября',
|
||||
'sk-SK': 'sobota 12. októbra',
|
||||
'tr-TR': '12 Ekim Cumartesi',
|
||||
'uk-UA': 'суботу, 12 жовтня',
|
||||
'uk-UA': 'субота, 12 жовтня',
|
||||
'zh-CN': '10月12日星期六',
|
||||
'zh-Hans': '10月12日星期六',
|
||||
'zh-Hans-CN': '10月12日星期六',
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
diff --git a/node_modules/swc-to-babel/lib/swc/index.js b/node_modules/swc-to-babel/lib/swc/index.js
|
||||
index ab285b3..a58a61d 100644
|
||||
--- a/node_modules/swc-to-babel/lib/swc/index.js
|
||||
+++ b/node_modules/swc-to-babel/lib/swc/index.js
|
||||
@@ -143,6 +143,15 @@ module.exports.ClassMethod = (path) => {
|
||||
key,
|
||||
});
|
||||
|
||||
+ if (node.kind === 'getter') {
|
||||
+ node.kind = 'get';
|
||||
+ }
|
||||
+ if (node.kind === 'setter') {
|
||||
+ node.kind = 'set';
|
||||
+ }
|
||||
+
|
||||
+ node.static = node.isStatic;
|
||||
+
|
||||
delete path.node.isStatic;
|
||||
delete path.node.accessibility;
|
||||
delete path.node.isAbstract;
|
||||
@@ -301,7 +310,7 @@ module.exports.TSIndexedAccessType = (path) => {
|
||||
module.exports.ImportDeclaration = ({node}) => {
|
||||
const {typeOnly} = node;
|
||||
|
||||
- node.assertions = node.asserts || [];
|
||||
+ node.assertions = node.asserts?.properties || [];
|
||||
node.importKind = typeOnly ? 'type' : 'value';
|
||||
|
||||
delete node.asserts;
|
||||
@@ -340,9 +349,10 @@ module.exports.convertGetterSetter = ({node}) => {
|
||||
};
|
||||
|
||||
module.exports.ExportDefaultDeclaration = ({node}) => {
|
||||
- node.declaration = node.decl;
|
||||
+ // node.declaration may have been already provided by convertExportDefaultExpression
|
||||
+ node.declaration = node.declaration || node.decl;
|
||||
node.exportKind = 'value';
|
||||
- node.assertions = [];
|
||||
+ node.assertions = node.asserts?.properties || [];
|
||||
|
||||
delete node.decl;
|
||||
};
|
||||
@@ -350,8 +360,8 @@ module.exports.ExportDefaultDeclaration = ({node}) => {
|
||||
module.exports.ExportNamedDeclaration = ({node}) => {
|
||||
const {typeOnly} = node;
|
||||
|
||||
- node.assertions = [];
|
||||
- node.source = null;
|
||||
+ node.assertions = node.asserts?.properties || [];
|
||||
+ // node.source = null;
|
||||
node.specifiers = node.specifiers || [];
|
||||
|
||||
node.exportKind = typeOnly ? 'type' : 'value';
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const lockFileContent = fs.readFileSync(path.resolve('./package-lock.json'), 'utf8');
|
||||
|
||||
const allowedRegistries = ['registry.yarnpkg.com', 'registry.npmjs.org'];
|
||||
const resolvedUrls = lockFileContent.match(/"resolved": "https:.*"/g);
|
||||
resolvedUrls?.forEach(url => {
|
||||
const [, registry] = url.match(/^"resolved": "https:\/\/(.*?)\/.*"$/) || [];
|
||||
if (!allowedRegistries.includes(registry)) {
|
||||
throw new Error(
|
||||
`Disallowed registries ("${registry}") in your package-lock.json!
|
||||
Please make sure you are using a public npm registry when downloading your dependencies!`,
|
||||
);
|
||||
}
|
||||
});
|
||||
17
scripts/lock-scan.mjs
Normal file
17
scripts/lock-scan.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
function containsDisallowedRegistry(url) {
|
||||
const [, registry] = url.match(/^"resolved": "https:\/\/(.*?)\/.*"$/) || [];
|
||||
return !['registry.yarnpkg.com', 'registry.npmjs.org'].includes(registry);
|
||||
}
|
||||
|
||||
const lockFileContent = fs.readFileSync(path.resolve('./package-lock.json'), 'utf8');
|
||||
const resolvedUrls = lockFileContent.match(/"resolved": "https:.*"/g);
|
||||
|
||||
if (resolvedUrls?.some(containsDisallowedRegistry)) {
|
||||
throw new Error(
|
||||
`Disallowed registries in your package-lock.json!
|
||||
Please make sure you are using a public npm registry when downloading your dependencies!`,
|
||||
);
|
||||
}
|
||||
|
|
@ -3,10 +3,8 @@
|
|||
const { chromium } = require('playwright');
|
||||
const looksSame = require('looks-same');
|
||||
const { join } = require('path');
|
||||
const mkdirp = require('mkdirp-promise');
|
||||
const fs = require('fs');
|
||||
const { promisify } = require('es6-promisify');
|
||||
const minimist = require('minimist');
|
||||
const { promisify } = require('util');
|
||||
const { mdjsTransformer } = require('@mdjs/core');
|
||||
const { createConfig, startServer } = require('es-dev-server');
|
||||
const nodePath = require('path');
|
||||
|
|
@ -14,7 +12,6 @@ const nodePath = require('path');
|
|||
const access = promisify(fs.access);
|
||||
const compareScreenshots = promisify(looksSame);
|
||||
const createScreenshotsDiff = promisify(looksSame.createDiff);
|
||||
const args = minimist(process.argv);
|
||||
|
||||
const DIFF_FOLDER_PREFIX = '.diff';
|
||||
const CURRENT_FOLDER_PREFIX = '.current';
|
||||
|
|
@ -157,7 +154,7 @@ async function getScreenshot({ root, id, selector, page, clip }) {
|
|||
|
||||
const { path, folder } = await buildPath({ root, id, selector });
|
||||
|
||||
mkdirp(folder);
|
||||
await fs.promises.mkdir(folder, { recursive: true });
|
||||
|
||||
// Remove caret from screenshots to avoid caret diff
|
||||
await page.evaluate(() => {
|
||||
|
|
@ -201,7 +198,7 @@ const screenshotsCompareOptions = {
|
|||
async function invalidateScreenshots({ diffRoot: root, id, selector, reference, current }) {
|
||||
const { path, folder } = await buildPath({ root, id, selector });
|
||||
|
||||
mkdirp(folder);
|
||||
await fs.promises.mkdir(folder, { recursive: true });
|
||||
|
||||
await createScreenshotsDiff({
|
||||
...screenshotsCompareOptions,
|
||||
|
|
@ -238,10 +235,11 @@ async function validateScreenshot(suite) {
|
|||
}
|
||||
}
|
||||
|
||||
let updateScreenshots = args['update-screenshots'] || process.env.UPDATE_SCREENSHOTS;
|
||||
let updateScreenshots =
|
||||
process.argv.includes('--update-screenshots') || process.env.UPDATE_SCREENSHOTS;
|
||||
|
||||
try {
|
||||
const avaConfig = JSON.parse(args._[2]);
|
||||
const avaConfig = JSON.parse(process.argv[2]);
|
||||
updateScreenshots = avaConfig.updateScreenshots;
|
||||
} catch (e) {
|
||||
log('Could not parse config');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import fs from 'fs';
|
||||
import { playwrightLauncher } from '@web/test-runner-playwright';
|
||||
|
||||
const devMode = process.argv.includes('--dev-mode');
|
||||
|
||||
const packages = fs
|
||||
.readdirSync('packages')
|
||||
.filter(
|
||||
|
|
@ -33,7 +35,7 @@ const testRunnerHtml = testRunnerImport =>
|
|||
`;
|
||||
|
||||
export default {
|
||||
nodeResolve: true,
|
||||
nodeResolve: { exportConditions: [devMode && 'development'] },
|
||||
coverageConfig: {
|
||||
report: true,
|
||||
reportDir: 'coverage',
|
||||
|
|
|
|||
Loading…
Reference in a new issue