Skip to content

Commit

Permalink
fix: missing deps
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko committed Nov 14, 2020
1 parent 9122db6 commit 6089364
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 149 deletions.
4 changes: 4 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: ['@commercetools-frontend/babel-preset-mc-app'],
plugins: ['babel-plugin-import-graphql', 'import-postcss'],
};
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"license": "MIT",
"private": true,
"scripts": {
"postinstall": "preconstruct dev",
"auth": "npm_config_registry=https://registry.npmjs.org npm whoami",
"clean": "lerna exec 'rm -rf build dist'",
"extract-intl": "formatjs extract --format=$(pwd)/packages/i18n/transifex-transformer.js --out-file=$(pwd)/packages/i18n/data/core.json 'packages/**/*messages.ts'",
Expand Down Expand Up @@ -69,12 +70,15 @@
]
},
"preconstruct": {
"___experimentalFlags_WILL_CHANGE_IN_PATCH": {
"logCompiledFiles": true
},
"packages": [
"packages-backend/*",
"packages/!(assets|babel-preset-mc-app|eslint-config-mc-app|jest-preset-mc-app|jest-stylelint-runner|mc-dev-authentication)"
]
},
"devDependencies": {
"dependencies": {
"@babel/cli": "7.12.1",
"@babel/core": "7.12.3",
"@changesets/changelog-github": "0.2.7",
Expand Down Expand Up @@ -205,5 +209,8 @@
"node": ">=12",
"npm": ">=5",
"yarn": ">=1.10"
},
"devDependencies": {
"babel-plugin-import-postcss": "2.0.0"
}
}
18 changes: 4 additions & 14 deletions packages-backend/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@
"directory": "packages-backend/express"
},
"homepage": "https://docs.commercetools.com/custom-applications",
"keywords": [
"javascript",
"nodejs",
"express",
"http",
"server",
"toolkit"
],
"keywords": ["javascript", "nodejs", "express", "http", "server", "toolkit"],
"license": "MIT",
"private": false,
"publishConfig": {
Expand All @@ -26,17 +19,14 @@
"module": "dist/express.esm.js",
"typings": "./build/index.d.ts",
"types": "./build/index.d.ts",
"files": [
"dist",
"package.json",
"LICENSE",
"README.md"
],
"files": ["dist", "package.json", "LICENSE", "README.md"],
"scripts": {
"prebuild": "rimraf build/**",
"build": "tsc -p tsconfig.build.json"
},
"dependencies": {
"@babel/runtime": "7.12.5",
"@babel/runtime-corejs3": "7.12.5",
"@types/node": "14.14.6",
"express": "4.17.1",
"express-jwt": "6.0.0",
Expand Down
9 changes: 3 additions & 6 deletions packages-backend/loggers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@
"module": "dist/loggers.esm.js",
"typings": "./build/index.d.ts",
"types": "./build/index.d.ts",
"files": [
"dist",
"package.json",
"LICENSE",
"README.md"
],
"files": ["dist", "package.json", "LICENSE", "README.md"],
"scripts": {
"prebuild": "rimraf build/**",
"build": "tsc -p tsconfig.build.json"
},
"dependencies": {
"@babel/runtime": "7.12.5",
"@babel/runtime-corejs3": "7.12.5",
"@sentry/node": "5.27.3",
"@types/triple-beam": "1.3.2",
"express-winston": "4.0.5",
Expand Down
15 changes: 3 additions & 12 deletions packages/actions-global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"directory": "packages/actions-global"
},
"homepage": "https://docs.commercetools.com/custom-applications",
"keywords": [
"javascript",
"frontend",
"react",
"toolkit"
],
"keywords": ["javascript", "frontend", "react", "toolkit"],
"license": "MIT",
"private": false,
"publishConfig": {
Expand All @@ -24,12 +19,7 @@
"module": "dist/actions-global.esm.js",
"typings": "./dist/typings/index.d.ts",
"types": "./dist/typings/index.d.ts",
"files": [
"dist",
"package.json",
"LICENSE",
"README.md"
],
"files": ["dist", "package.json", "LICENSE", "README.md"],
"scripts": {
"prepare": "./../../scripts/version.js replace",
"prebuild": "rimraf dist/**",
Expand All @@ -44,6 +34,7 @@
"@commercetools-frontend/browser-history": "17.3.0",
"@commercetools-frontend/constants": "17.3.0",
"@commercetools-frontend/notifications": "17.3.0",
"@commercetools-frontend/sentry": "17.3.0",
"@types/lodash": "^4.14.155",
"lodash": "4.17.20",
"lodash-es": "4.17.15",
Expand Down
11 changes: 5 additions & 6 deletions packages/application-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"directory": "packages/application-components"
},
"homepage": "https://docs.commercetools.com/custom-applications",
"keywords": [
"javascript",
"frontend",
"react",
"toolkit"
],
"keywords": ["javascript", "frontend", "react", "toolkit"],
"license": "MIT",
"private": false,
"publishConfig": {
Expand Down Expand Up @@ -48,13 +43,17 @@
"@commercetools-uikit/card": "^10.39.8",
"@commercetools-uikit/constraints": "^10.39.8",
"@commercetools-uikit/design-system": "^10.39.8",
"@commercetools-uikit/flat-button": "^10.39.8",
"@commercetools-uikit/icon-button": "^10.39.8",
"@commercetools-uikit/icons": "^10.39.8",
"@commercetools-uikit/primary-button": "^10.39.8",
"@commercetools-uikit/secondary-button": "^10.39.8",
"@commercetools-uikit/secondary-icon-button": "^10.39.8",
"@commercetools-uikit/spacings": "^10.39.8",
"@commercetools-uikit/text": "10.39.8",
"@emotion/core": "10.1.1",
"@emotion/styled": "10.0.27",
"@emotion/styled-base": "10.0.31",
"@types/lodash": "^4.14.155",
"@types/prop-types": "^15.7.3",
"@types/react-modal": "^3.10.4",
Expand Down
24 changes: 6 additions & 18 deletions packages/application-shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"directory": "packages/application-shell"
},
"homepage": "https://docs.commercetools.com/custom-applications",
"keywords": [
"javascript",
"frontend",
"react",
"toolkit"
],
"keywords": ["javascript", "frontend", "react", "toolkit"],
"license": "MIT",
"private": false,
"publishConfig": {
Expand All @@ -24,18 +19,9 @@
"module": "dist/application-shell.esm.js",
"typings": "./dist/typings/index.d.ts",
"types": "./dist/typings/index.d.ts",
"files": [
"dist",
"test-utils",
"package.json",
"LICENSE",
"README.md"
],
"files": ["dist", "test-utils", "package.json", "LICENSE", "README.md"],
"preconstruct": {
"entrypoints": [
".",
"test-utils"
]
"entrypoints": [".", "test-utils"]
},
"scripts": {
"prepare": "./../../scripts/version.js replace",
Expand Down Expand Up @@ -73,12 +59,14 @@
"@commercetools-uikit/select-input": "^10.39.8",
"@commercetools-uikit/spacings": "^10.39.8",
"@commercetools-uikit/text": "^10.39.8",
"@commercetools/http-user-agent": "2.1.2",
"@emotion/core": "10.1.1",
"@emotion/styled": "10.0.27",
"@emotion/styled-base": "10.0.31",
"@flopflip/launchdarkly-adapter": "2.15.7",
"@flopflip/types": "2.5.10",
"@flopflip/memory-adapter": "1.9.7",
"@flopflip/react-broadcast": "10.2.8",
"@flopflip/types": "2.5.10",
"@types/classnames": "^2.2.9",
"@types/common-tags": "^1.8.0",
"@types/history": "^4.7.6",
Expand Down
6 changes: 4 additions & 2 deletions packages/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@
},
"devDependencies": {
"intl-messageformat-parser": "6.0.15",
"react": "16.14.0"
"react": "16.14.0",
"react-intl": "5.9.4"
},
"peerDependencies": {
"@types/react": "16.x",
"react": ">=16.8.0"
"react": ">=16.8.0",
"react-intl": "3.x || 4.x || 5.x"
}
}
16 changes: 3 additions & 13 deletions packages/permissions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
"directory": "packages/permissions"
},
"homepage": "https://docs.commercetools.com/custom-applications",
"keywords": [
"javascript",
"frontend",
"react",
"toolkit"
],
"keywords": ["javascript", "frontend", "react", "toolkit"],
"license": "MIT",
"private": false,
"publishConfig": {
Expand All @@ -24,12 +19,7 @@
"module": "dist/permissions.esm.js",
"typings": "./dist/typings/index.d.ts",
"types": "./dist/typings/index.d.ts",
"files": [
"dist",
"package.json",
"LICENSE",
"README.md"
],
"files": ["dist", "package.json", "LICENSE", "README.md"],
"scripts": {
"prepare": "./../../scripts/version.js replace",
"prebuild": "rimraf dist/**",
Expand All @@ -47,7 +37,7 @@
"lodash": "4.17.20",
"lodash-es": "4.17.15",
"prop-types": "15.7.2",
"tiny-warning": "1.0.3"
"tiny-invariant": "1.1.0"
},
"devDependencies": {
"react": "16.14.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { mocked } from 'ts-jest/utils';
import warning from 'tiny-warning';
import invariant from 'tiny-invariant';
import { ApplicationContextProvider } from '@commercetools-frontend/application-shell-connectors';
import { render as rtlRender } from '@testing-library/react';
import useIsAuthorized from './use-is-authorized';

jest.mock('tiny-warning');
jest.mock('tiny-invariant');

type TPermissionName = string;
type TAllAppliedPermission = {
Expand Down Expand Up @@ -672,7 +672,7 @@ describe('data fences', () => {

describe('warnings', () => {
beforeEach(() => {
mocked(warning).mockClear();
mocked(invariant).mockClear();
});
describe('with implied permissions', () => {
it('should warn to not specify the implied permissions', () => {
Expand All @@ -681,13 +681,13 @@ describe('warnings', () => {
demandedPermissions: ['ViewOrders', 'ManageOrders'],
});

expect(warning).toHaveBeenCalledWith(
expect(invariant).toHaveBeenCalledWith(
false,
expect.stringContaining(
'Demanded permissions contain implied permissions.'
)
);
expect(warning).toHaveBeenCalledWith(
expect(invariant).toHaveBeenCalledWith(
false,
expect.stringContaining('ViewOrders')
);
Expand All @@ -700,7 +700,7 @@ describe('warnings', () => {
demandedPermissions: ['ViewOrders', 'ManageOrders'],
});

expect(warning).toHaveBeenCalledWith(
expect(invariant).toHaveBeenCalledWith(
false,
expect.stringContaining(
'It is recommended to pass a single demanded permission'
Expand All @@ -719,7 +719,7 @@ describe('warnings', () => {
],
});

expect(warning).toHaveBeenCalledWith(
expect(invariant).toHaveBeenCalledWith(
false,
expect.stringContaining(
'It is recommended to pass a single demanded action right'
Expand All @@ -736,7 +736,7 @@ describe('warnings', () => {
shouldMatchSomePermissions: true,
});

expect(warning).toHaveBeenCalledWith(
expect(invariant).toHaveBeenCalledWith(
false,
expect.stringContaining(
"It is recommended not to use 'shouldMatchSomePermissions'"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import warning from 'tiny-warning';
import invariant from 'tiny-invariant';
import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors';
import { reportErrorToSentry } from '@commercetools-frontend/sentry';
import {
Expand Down Expand Up @@ -52,12 +52,6 @@ type TSelectDataFenceData = (
}
) => string[] | null;

const useWarning = (condition: boolean, message: string) => {
React.useEffect(() => {
warning(condition, message);
}, [condition, message]);
};

const useIsAuthorized = ({
demandedPermissions,
demandedActionRights,
Expand All @@ -73,19 +67,19 @@ const useIsAuthorized = ({
}) => {
const impliedPermissions = getImpliedPermissions(demandedPermissions);

useWarning(
invariant(
!demandedActionRights || demandedActionRights.length === 1,
`@commercetools-frontend/permissions: It is recommended to pass a single demanded action right while using the hook, HoC or component multiple times.`
);
useWarning(
invariant(
!demandedPermissions || demandedPermissions.length === 1,
`@commercetools-frontend/permissions: It is recommended to pass a single demanded permission while using the hook, HoC or component multiple times.`
);
useWarning(
invariant(
shouldMatchSomePermissions === false,
`@commercetools-frontend/permissions: It is recommended not to use 'shouldMatchSomePermissions' but instead use the hook, HoC or component multiple times.`
);
useWarning(
invariant(
!impliedPermissions || impliedPermissions.length === 0,
`@commercetools-frontend/permissions: Demanded permissions contain implied permissions. These are implied: ${impliedPermissions.join(
', '
Expand Down
Loading

0 comments on commit 6089364

Please sign in to comment.