Skip to content

Commit

Permalink
fix: remove dependency on packages that are fetched from GitHub
Browse files Browse the repository at this point in the history
Corporate internal systems may not always allow access to GitHub.
So, any dependencies that are fetched from GitHub (codeload.github.com)
may be blocked, hance, failing the install process.

Best uses an old version of `lwc-services` that has a dependency
on one such package (i.e.: `lwc-jest-preset-ts-fix`¹) that was never
published, and thus, needs to be fetched from GitHub. Newer versions
of `lwc-services` no longer depend² on `lwc-jest-preset-ts-fix`.

This commit fixes the issues described above by updating `lwc-services`
to the latest available version (i.e. `v3.2.2`) and includes all the
related changes required by the update.

Note: Since `lwc-services` is now deprecated³, in the future, we will
      look into removing it altogether.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

¹ https://github.com/muenzpraeger/lwc-jest-preset-ts-fix
² salesforce/lwc-test#36
³ https://www.npmjs.com/package/lwc-services
  • Loading branch information
sf-v committed Aug 11, 2022
1 parent 9deec13 commit 8a93201
Show file tree
Hide file tree
Showing 18 changed files with 5,719 additions and 6,067 deletions.
12 changes: 6 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"winston": "~3.1.0"
},
"devDependencies": {
"@lwc/compiler": "~1.0.0",
"@lwc/engine": "~1.0.0",
"@lwc/jest-preset": "~1.0.0",
"@lwc/rollup-plugin": "~1.0.0",
"@lwc/synthetic-shadow": "~1.0.0",
"@lwc/wire-service": "~1.0.0",
"@lwc/compiler": "2.5.13",
"@lwc/engine": "1.17.6",
"@lwc/jest-preset": "11.2.1",
"@lwc/rollup-plugin": "2.22.0",
"@lwc/synthetic-shadow": "2.22.0",
"@lwc/wire-service": "2.22.0",
"cpy": "~7.0.1",
"cross-env": "^5.2.0",
"dateformat": "^3.0.3",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@commitlint/config-conventional": "16.2.4",
"@types/debug": "0.0.30",
"@types/express": "4.17.13",
"@types/jest": "^26.0.0",
"@types/jest": "27.5.1",
"@types/jsonwebtoken": "8.5.8",
"@types/micromatch": "^3.1.0",
"@types/mime-types": "2.1.1",
Expand All @@ -32,7 +32,8 @@
"eslint": "^5.16.0",
"husky": "2.4.0",
"isbinaryfile": "^4.0.2",
"jest": "^26.0.1",
"jest": "27.5.1",
"jest-environment-jsdom": "27.5.1",
"jsonwebtoken": "8.5.1",
"lerna": "^3.18.3",
"prettier": "2.6.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/@best/agent-frontend/lwc-services.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

// Find the full example of all available configuration options at
// https://github.com/muenzpraeger/lwc-create-app/blob/master/packages/lwc-services/example/lwc-services.config.js
// https://github.com/muenzpraeger/create-lwc-app/blob/main/packages/lwc-services/example/lwc-services.config.js
module.exports = {
resources: [{ from: 'src/client/resources', to: 'dist/resources' }],
resources: [{ from: 'src/client/resources/', to: 'dist/resources/' }],
sourceDir: './src/client',
moduleDir: './src/client/modules',
};
7 changes: 7 additions & 0 deletions packages/@best/agent-frontend/lwc.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"modules": [
{
"dir": "src/client/modules"
}
]
}
3 changes: 2 additions & 1 deletion packages/@best/agent-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"dependencies": {
"@babel/helper-create-class-features-plugin": "7.18.9",
"@best/shared": "7.0.0",
"express": "4.18.1",
"lwc-services": "~1.3.12",
"lwc-services": "3.2.2",
"socket.io": "~2.2.0",
"socket.io-client": "~2.2.0"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/@best/frontend/lwc-services.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/

// Find the full example of all available configuration options at
// https://github.com/muenzpraeger/create-lwc-app/blob/main/packages/lwc-services/example/lwc-services.config.js
module.exports = {
resources: [{ from: 'src/resources', to: 'dist/resources' }],
resources: [{ from: 'src/resources/', to: 'dist/resources/' }],
moduleDir: './src/modules'
};
7 changes: 7 additions & 0 deletions packages/@best/frontend/lwc.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"modules": [
{
"dir": "src/modules"
}
]
}
32 changes: 16 additions & 16 deletions packages/@best/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@
"@best/console-stream": "7.0.0",
"@best/github-integration": "7.0.0",
"@best/types": "7.0.0",
"@lwc/compiler": "^1.0.0",
"@lwc/engine": "^1.0.0",
"@lwc/rollup-plugin": "^1.0.0",
"@lwc/compiler": "2.5.13",
"@lwc/engine": "^1.17.6",
"@lwc/rollup-plugin": "2.22.0",
"compression": "^1.7.4",
"express": "4.18.1",
"jsonwebtoken": "^8.5.1",
"lwc-services": "^1",
"query-string": "^6.6.0",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"rollup": "~1.26.0",
"lwc-services": "3.2.2",
"query-string": "^7.1.1",
"redux": "^4.0.5",
"redux-thunk": "^2.4.1",
"rollup": "^2.38.0",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.3",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^5.0.0"
"@rollup/plugin-replace": "4.0.0",
"rollup-plugin-terser": "^7.0.2"
},
"devDependencies": {
"@types/compression": "^0.0.36",
"@types/compression": "^1.7.2",
"@types/express": "4.17.13",
"@types/helmet": "^0.0.43",
"@types/helmet": "^4.0.0",
"@types/jsonwebtoken": "8.5.8",
"concurrently": "^4.1.0",
"fetch-mock": "^7.3.3",
"nodemon": "^1.19.1",
"concurrently": "^7.3.0",
"fetch-mock": "^9.11.0",
"nodemon": "^2.0.19",
"redux-mock-store": "^1.5.3",
"ts-node": "^8.2.0"
"ts-node": "^10.9.1"
},
"files": [
"build/**/*.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/@best/frontend/server/static/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import path from 'path';
import lwc from '@lwc/rollup-plugin';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import replace from 'rollup-plugin-replace';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import { bestMocker, MockerOptions } from './mocker'
import * as rollup from 'rollup';
Expand Down Expand Up @@ -39,4 +39,4 @@ export const buildRollupConfig = (projectConfig: FrozenProjectConfig): {
format: 'iife'
})
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LightningElement, track, api, wire } from 'lwc';
import { drawPlot, buildTrends, buildLayout, relayout, createAnnotation, removeAnnotation } from './plots';

import { connectStore, store } from 'store/store';
import { ConnectStore, store } from 'store/store';
import { fetchComparison, comparisonChanged } from 'store/actions';

export default class ComponentBenchmark extends LightningElement {
Expand All @@ -22,11 +22,13 @@ export default class ComponentBenchmark extends LightningElement {

@api metric = 'all';

@wire(connectStore, { store })
// eslint-disable-next-line @lwc/lwc/no-unknown-wire-adapters
@wire(ConnectStore, { store })
storeChanged({ view }) {
this.comparisonResults = view.comparison.results;
this.viewComparisonCommits = view.comparison.commits;
this.comparisonName = view.comparison.benchmarkName;
// eslint-disable-next-line @lwc/lwc/no-api-reassignments
this.metric = view.metric;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LightningElement, api, track, wire } from 'lwc';

import { connectStore, store } from 'store/store';
import { ConnectStore, store } from 'store/store';
import { fetchCommitInfoIfNeeded } from 'store/actions';

export default class ComponentCommitInfo extends LightningElement {
Expand All @@ -12,7 +12,8 @@ export default class ComponentCommitInfo extends LightningElement {

@track commitInfo = {};

@wire(connectStore, { store })
// eslint-disable-next-line @lwc/lwc/no-unknown-wire-adapters
@wire(ConnectStore, { store })
storeChanged({ commitInfo }) {
this.commitInfo = commitInfo[this.commit];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LightningElement, track, wire } from 'lwc';

import { connectStore, store } from 'store/store';
import { ConnectStore, store } from 'store/store';
import { timingChanged, benchmarksChanged, metricsChanged, zoomChanged } from 'store/actions';

export default class ComponentMenubar extends LightningElement {
Expand All @@ -12,7 +12,8 @@ export default class ComponentMenubar extends LightningElement {
@track viewMetric;
@track viewZoom = {};

@wire(connectStore, { store })
// eslint-disable-next-line @lwc/lwc/no-unknown-wire-adapters
@wire(ConnectStore, { store })
storeChange({ benchmarks, view }) {
this.benchmarkNames = benchmarks.items.map((bench) => bench.name);

Expand Down
2 changes: 1 addition & 1 deletion packages/@best/frontend/src/modules/store/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ export const store = createStore(
applyMiddleware(thunk, urlstorage.middleware),
);

export { connectStore } from './wire-adapter';
export { ConnectStore } from './wire-adapter';
62 changes: 38 additions & 24 deletions packages/@best/frontend/src/modules/store/store/wire-adapter.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
import { register, ValueChangedEvent } from '@lwc/wire-service';
export class ConnectStore {
connected = false;
dataCallback;
store;
subscription;

export function connectStore(store) {
return store.getState();
}

register(connectStore, (eventTarget) => {
let store;
let subscription;
constructor(dataCallback) {
this.dataCallback = dataCallback;
}

const notifyStateChange = () => {
const state = store.getState();
eventTarget.dispatchEvent(new ValueChangedEvent(state));
};
connect() {
this.connected = true;
this.subscribeToStore();
}

eventTarget.addEventListener('connect', () => {
subscription = store.subscribe(notifyStateChange);
notifyStateChange();
});
disconnect() {
this.unsubscribeFromStore();
this.connected = false;
}

eventTarget.addEventListener('disconnect', () => {
if (subscription) {
subscription();
subscribeToStore() {
if (this.connected && this.store) {
const notifyStateChange = () => {
const state = this.store.getState();
this.dataCallback(state);
};
this.subscription = this.store.subscribe(notifyStateChange);
notifyStateChange();
}
});
}

update(config) {
this.unsubscribeFromStore();
this.store = config.store;
this.subscribeToStore();
}

eventTarget.addEventListener('config', (config) => {
store = config.store;
});
});
unsubscribeFromStore() {
if (this.subscription) {
this.subscription();
this.subscription = undefined;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LightningElement, track, wire } from 'lwc';

import { connectStore, store } from 'store/store';
import { ConnectStore, store } from 'store/store';
import { zoomChanged } from 'store/actions';

export default class ViewBenchmarks extends LightningElement {
Expand All @@ -11,7 +11,8 @@ export default class ViewBenchmarks extends LightningElement {

@track viewZoom;

@wire(connectStore, { store })
// eslint-disable-next-line @lwc/lwc/no-unknown-wire-adapters
@wire(ConnectStore, { store })
storeChange({ benchmarks, view }) {
if (view.benchmark === 'all') {
this.visibleBenchmarks = benchmarks.items;
Expand Down
5 changes: 3 additions & 2 deletions packages/@best/frontend/src/modules/view/sidebar/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LightningElement, track, wire } from 'lwc';

import { connectStore, store } from 'store/store';
import { ConnectStore, store } from 'store/store';
import { selectProject } from 'store/actions';

export default class ViewSidebar extends LightningElement {
Expand All @@ -9,7 +9,8 @@ export default class ViewSidebar extends LightningElement {

hasSelectedInitialProject = false;

@wire(connectStore, { store })
// eslint-disable-next-line @lwc/lwc/no-unknown-wire-adapters
@wire(ConnectStore, { store })
storeChange({ projects }) {
this.selectedId = projects.selectedProjectId;

Expand Down
6 changes: 3 additions & 3 deletions packages/lwc-example/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"dependencies": {
"@lwc/engine": "~1.0.0",
"@lwc/rollup-plugin": "~1.0.0",
"@lwc/engine": "~1.17.6",
"@lwc/rollup-plugin": "2.22.0",
"best": "7.0.0",
"rollup-plugin-replace": "~2.2.0"
"@rollup/plugin-replace": "4.0.0"
},
"name": "lwc-examples",
"private": true,
Expand Down
Loading

0 comments on commit 8a93201

Please sign in to comment.