Skip to content

Commit

Permalink
fix: internal packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tracy-french committed Dec 9, 2024
1 parent 65c2024 commit 93ae314
Show file tree
Hide file tree
Showing 141 changed files with 2,975 additions and 15,695 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
${{ runner.os }}-test-lint-${{ matrix.package}}-
- name: Validate
run: npx turbo build:cjs build:es lint test --filter=@iot-app-kit/${{ matrix.package }}
run: npx turbo build lint test --filter=@iot-app-kit/${{ matrix.package }}

playwright:
needs: repo
Expand Down
11 changes: 0 additions & 11 deletions .stylelintignore

This file was deleted.

17 changes: 16 additions & 1 deletion apps/dev-env/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
const base = require('@iot-app-kit/eslint-config');

module.exports = {
...base,
root: true,
extends: ['iot-app-kit'],
settings: {
...base.settings,
'import/resolver': {
...base.settings['import/resolver'],
typescript: {
...base.settings['import/resolver'].typescript,
project: ['apps/dev-env/tsconfig.json'],
},
node: {
project: ['apps/dev-env/tsconfig.json'],
},
},
},
};
2 changes: 1 addition & 1 deletion apps/dev-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@iot-app-kit/core-util": "*",
"@iot-app-kit/dashboard": "*",
"@iot-app-kit/data-mocked": "*",
"@iot-app-kit/eslint-config": "*",
"@iot-app-kit/helpers": "*",
"@iot-app-kit/ts-config": "*",
"@playwright/test": "^1.48.2",
Expand All @@ -34,7 +35,6 @@
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.16.18",
"@vitejs/plugin-react": "^4.3.3",
"eslint-config-iot-app-kit": "*",
"lodash-es": "^4.17.21",
"msw-storybook-addon": "^2.0.4",
"react": "^18.2.0",
Expand Down
5 changes: 1 addition & 4 deletions apps/dev-env/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
MINUTE_IN_MS,
SECOND_IN_MS,
} from '@iot-app-kit/helpers/constants/time';
import { MINUTE_IN_MS, SECOND_IN_MS } from '@iot-app-kit/helpers';
import { defineConfig, devices } from '@playwright/test';

/**
Expand Down
6 changes: 6 additions & 0 deletions apps/doc-site/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const base = require('@iot-app-kit/eslint-config');

module.exports = {
...base,
root: true,
};
4 changes: 0 additions & 4 deletions apps/doc-site/.eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions apps/doc-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"fix": "eslint --fix . --cache --cache-location .cache/eslint/"
},
"devDependencies": {
"@iot-app-kit/testing-util": "12.2.1",
"@iot-app-kit/eslint-config": "*",
"@iot-app-kit/testing-util": "*",
"@storybook/addon-essentials": "^8.4.5",
"@storybook/addon-interactions": "^8.4.5",
"@storybook/addon-links": "^8.4.5",
Expand All @@ -26,7 +27,6 @@
"@storybook/theming": "^8.4.5",
"@types/node": "^18.16.18",
"@vitejs/plugin-react": "^4.3.3",
"eslint-config-iot-app-kit": "12.2.1",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
4 changes: 3 additions & 1 deletion configuration/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ module.exports = {
pragma: 'h',
},
'import/resolver': {
typescript: true,
typescript: {
conditionNames: ['@iot-app-kit/development'],
},
node: true,
},
},
Expand Down
12 changes: 6 additions & 6 deletions configuration/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "eslint-config-iot-app-kit",
"name": "@iot-app-kit/eslint-config",
"version": "12.2.1",
"main": "index.js",
"private": true,
"files": [
"index.js"
],
"exports": {
".": "./index.js"
},
"scripts": {
"clean:nuke": "rimraf node_modules"
},
Expand All @@ -31,6 +32,5 @@
"@types/node": "^18.16.18",
"eslint-import-resolver-typescript": "^3.6.0",
"typescript": "^5.5.4"
},
"version": "12.2.1"
}
}
28 changes: 28 additions & 0 deletions configuration/packaging/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@iot-app-kit/packaging",
"version": "12.2.1",
"private": true,
"files": [
"dist"
],
"type": "module",
"exports": {
".": "./src/prepack.cts"
},
"scripts": {
"clean": "rimraf .cache .turbo",
"clean:nuke": "npm run clean && rimraf node_modules"
},
"devDependencies": {
"@iot-app-kit/eslint-config": "*",
"@iot-app-kit/ts-config": "*",
"@types/node": "^18.16.18",
"fs-extra": "^11.2.0",
"lodash-es": "^4.17.21",
"rimraf": "^5.0.1",
"rollup-plugin-copy": "^3.5.0",
"typescript": "^5.5.4",
"vite": "^5.4.11",
"vite-plugin-dts": "^4.3.0"
}
}
21 changes: 21 additions & 0 deletions configuration/packaging/src/postpack.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env -S npx tsx
import * as fse from 'fs-extra';

function postpack() {
const sharedDependencies = process.argv.slice(2);

revertSharedPackageVersions(sharedDependencies);
}

function revertSharedPackageVersions(sharedDependencies: string[]) {
const packageJsonPath = './package.json';
const packageJson = fse.readJSONSync(packageJsonPath);

sharedDependencies.forEach((dep) => {
packageJson.dependencies[`@iot-app-kit/${dep}`] = '*';
});

fse.writeJSONSync(packageJsonPath, packageJson, { spaces: 2 });
}

postpack();
22 changes: 22 additions & 0 deletions configuration/packaging/src/prepack.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env -S npx tsx
import * as fse from 'fs-extra';

function prepack() {
const sharedDependencies = process.argv.slice(2);

setSharedPackageVersions(sharedDependencies);
}

function setSharedPackageVersions(sharedDependencies: string[]) {
const packageJsonPath = './package.json';
const packageJson = fse.readJSONSync(packageJsonPath);
console.log(packageJson);

sharedDependencies.forEach((dep) => {
packageJson.dependencies[`@iot-app-kit/${dep}`] = `file:./dist/${dep}`;
});

fse.writeJSONSync(packageJsonPath, packageJson, { spaces: 2 });
}

prepack();
5 changes: 5 additions & 0 deletions configuration/packaging/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@iot-app-kit/ts-config/tsconfig.base.json",
"include": ["src"]
}
6 changes: 3 additions & 3 deletions configuration/ts-config/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@iot-app-kit/ts-config",
"type": "module",
"version": "12.2.1",
"private": true,
"type": "module",
"files": [
"tsconfig.base.json",
"tsconfig.cjs.json",
Expand All @@ -14,6 +15,5 @@
"@types/node": "^18.16.18",
"rimraf": "^5.0.1",
"typescript": "^5.5.4"
},
"version": "12.2.1"
}
}
9 changes: 6 additions & 3 deletions configuration/ts-config/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"declaration": true,
"declarationDir": "dist",
"declarationMap": true,
"sourceMap": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
Expand All @@ -18,6 +20,7 @@
"module": "ESNext",
"moduleResolution": "bundler",
"target": "ESNEXT",
"jsx": "react-jsx"
"jsx": "react-jsx",
"customConditions": ["@iot-app-kit/development"]
}
}
3 changes: 2 additions & 1 deletion configuration/ts-config/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"incremental": true
"incremental": true,
"customConditions": null
}
}
19 changes: 19 additions & 0 deletions configuration/vite-config/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const base = require('@iot-app-kit/eslint-config');

module.exports = {
...base,
root: true,
settings: {
...base.settings,
'import/resolver': {
...base.settings['import/resolver'],
typescript: {
...base.settings['import/resolver'].typescript,
project: ['configuration/vite-config/tsconfig.json'],
},
node: {
project: ['configuration/vite-config/tsconfig.json'],
},
},
},
};
30 changes: 30 additions & 0 deletions configuration/vite-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@iot-app-kit/vite-config",
"private": true,
"type": "module",
"exports": {
"./definePackageConfig": "./src/definePackageConfig.ts"
},
"scripts": {
"clean": "rimraf .cache .turbo",
"clean:nuke": "npm run clean && rimraf node_modules",
"lint": "eslint . --max-warnings=0 --cache --cache-location .cache/eslint/",
"fix": "eslint --fix . --cache --cache-location ./cache/eslint/",
"test:typescript": "tsc --noEmit"
},
"devDependencies": {
"@iot-app-kit/eslint-config": "*",
"@iot-app-kit/ts-config": "*",
"@types/node": "^18.16.18",
"rimraf": "^5.0.1"
},
"dependencies": {
"fs-extra": "^11.2.0",
"lodash-es": "^4.17.21",
"rollup-plugin-copy": "^3.5.0",
"tiny-invariant": "^1.3.1",
"typescript": "^5.5.4",
"vite": "^5.4.11",
"vite-plugin-dts": "^4.3.0"
}
}
55 changes: 55 additions & 0 deletions configuration/vite-config/src/copyPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { resolve } from 'path';
import copy from 'rollup-plugin-copy';
import { Plugin } from 'vite';
import { listInstalledPackages } from './installedPackages';
import { type PackageName, type PackageShortName } from './package';
import { type PackageJson } from './packageJson';

export interface CopyPackagePluginOptions {
dir: string;
packageJson: PackageJson;
}

export function copyProtectedPackagesPlugin({
dir,
packageJson,
}: CopyPackagePluginOptions): Plugin {
const packagesToCopy = listInstalledPackages(packageJson, {
filter: { dependencyType: 'dependencies', scope: 'protected' },
});

// To enable installation of unpublished shared packages when an
// external consumer is installing an iot-app-kit package, the
// compiled code and the package.json file of each shared package is
// copied into the consuming package. The result of the copy is a
// something resembling what is installed into the external consumers
// node_modules.
return copy({
// Copy after the code is transformed.
hook: 'writeBundle',
targets: packagesToCopy.flatMap((iotAppKitPackage) => {
const packageShortName = getPackageShortName(iotAppKitPackage.name);

const packagePath = getSiblingPackagePath(packageShortName, dir);
const artifactsSrc = resolve(packagePath, 'dist');
const packageJSONSrc = resolve(packagePath, 'package.json');
const copyDest = resolve(dir, `dist/${packageShortName}`);

return [
{ src: artifactsSrc, dest: copyDest },
{ src: packageJSONSrc, dest: copyDest },
];
}),
});
}

function getPackageShortName(packageName: PackageName): PackageShortName {
return packageName.split('/')[1] as PackageShortName;
}

function getSiblingPackagePath(
siblingPackageShortName: string,
dirname: string
): string {
return resolve(dirname, `../${siblingPackageShortName}`);
}
Loading

0 comments on commit 93ae314

Please sign in to comment.