Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding script to build all components #232

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .scripts/build-components.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ComponentsBuilder } from "@nimbus-ds/scripts/src";

new ComponentsBuilder().exec();
2 changes: 1 addition & 1 deletion .scripts/build-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ try {
"@nimbus-ds/webpack",
];

const command = packageBuilder.getCommmandBuildNPM(
const command = packageBuilder.getCommandBuildNPM(
packagesToBuild,
removePackages
);
Expand Down
7 changes: 7 additions & 0 deletions .yarn/versions/dbb9baf6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
releases:
"@nimbus-ds/components": patch
"@nimbus-ds/scripts": minor

declined:
- nimbus-design-system
- nimbus-helper
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"scripts": {
"build": "yarn build:packages",
"build:packages": "yarn build:tokens && yarn build:icons && babel-node -x .ts ./.scripts/build-packages",
"build:packages": "yarn build:tokens && yarn build:icons && yarn build:components && babel-node -x .ts ./.scripts/build-packages",
"build:components": "babel-node -x .ts ./.scripts/build-components",
"build:docs": "babel-node -x .ts ./.scripts/json-documentation",
"build:icons": "turbo run build --filter=@nimbus-ds/icons",
"build:tokens": "turbo run build --filter=@nimbus-ds/tokens",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import fs from "fs";
import { PackageBuilder } from "../packageBuilder";

export class ComponentsBuilder {
private PATH = "./packages/react/src/";

private getComponentsFrom(path: string): string[] {
const components = [];
const atomicComponents = fs.readdirSync(`${this.PATH}/${path}`);
for (const atomicComponent of atomicComponents) {
const packageJsonContent = fs.readFileSync(
`${this.PATH}/${path}/${atomicComponent}/package.json`,
"utf-8"
);
const json = JSON.parse(packageJsonContent);
const componentName = json.name;
components.push(componentName);
}
return components;
}

public exec() {
const atomicComponents = this.getComponentsFrom("atomic");
const compositeComponents = this.getComponentsFrom("composite");

const componentsCommand = [...atomicComponents, ...compositeComponents]
.map((component) => `--filter=${component}`)
.join(" ");

new PackageBuilder().execCommand(`turbo run build ${componentsCommand}`);
}
}
1 change: 1 addition & 0 deletions packages/core/scripts/src/componentsBuilder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./ComponentsBuilder";
1 change: 1 addition & 0 deletions packages/core/scripts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./docgen";
export * from "./packageBuilder";
export * from "./componentsBuilder";
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class PackageBuilder {
);
}

public getCommmandBuildNPM(
public getCommandBuildNPM(
packages: string[],
removePackages: string[] = []
): string {
Expand Down
6 changes: 2 additions & 4 deletions packages/react/src/atomic/Popover/src/popover.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ describe("GIVEN <Popover />", () => {
false,
expect.objectContaining({
isTrusted: false,
}),
"click"
})
);
});

Expand All @@ -169,8 +168,7 @@ describe("GIVEN <Popover />", () => {
true,
expect.objectContaining({
isTrusted: false,
}),
"click"
})
);
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export * from "@nimbus-ds/title";
export * from "@nimbus-ds/toast";
export * from "@nimbus-ds/toggle";
export * from "@nimbus-ds/tooltip";

// composite
export * from "@nimbus-ds/accordion";
export * from "@nimbus-ds/alert";
Expand Down
Loading
Loading