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

Cleanup MRL / standardize more #1091

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .changeset/giant-crabs-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
70 changes: 48 additions & 22 deletions .monorepolint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,9 @@ const DELETE_SCRIPT_ENTRY = { options: [undefined], fixValue: undefined };

const nonStandardPackages = [
"@osdk/e2e.generated.1.1.x",
"@osdk/e2e.sandbox.todoapp",
"@osdk/e2e.sandbox.todowidget", // uses react
"@osdk/e2e.sandbox.oauth.public.react-router",
"@osdk/examples.*",
"@osdk/foundry-sdk-generator",
"@osdk/e2e.test.foundry-sdk-generator",
"@osdk/monorepo.*", // internal monorepo packages
"@osdk/tests.*",
"@osdk/widget-client-react.unstable", // uses react
"@osdk/widget.vite-plugin.unstable", // has a vite-bundled app + react
// removed the following from the repo to avoid it being edited
// "@osdk/shared.client2", // hand written package that only exposes a symbol
"@osdk/benchmarks.*",
Expand Down Expand Up @@ -77,13 +70,23 @@ const privatePackages = [
"@osdk/benchmarks.*",
];

// Package architypes (mutually exclusive)

const consumerCliPackages = [
"@osdk/cli",
"@osdk/create-app",
"@osdk/foundry-sdk-generator",
];

const testWithHappyDomPackages = [
const viteApp = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we move widgets out or want to make more sample apps in other repo's, we'd have to update these first? When we move the MRL config out, is it somehow possible to make these inputs of some sort so these names come from the repos that the packages live in themselves?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both this var and others

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is part of a temporary state. The goal will be to refactor this whole file to be a "library" where individual repos would "configure" it with the packages in their own repo that fit the various archetypes.

"@osdk/widget.vite-plugin.unstable",
"@osdk/e2e.sandbox.todowidget",
"@osdk/e2e.sandbox.todoapp",
"@osdk/e2e.sandbox.oauth.public.react-router",
];

const usesReact = [
"@osdk/widget-client-react.unstable",
"@osdk/react",
];

Expand Down Expand Up @@ -330,13 +333,20 @@ function getTsconfigOptions(baseTsconfigPath, opts) {
* esmOnly?: boolean,
* customTsconfigExcludes?: string[],
* tsVersion?: typeof LATEST_TYPESCRIPT_DEP | "^4.9.5",
* react?: boolean,
* extraPublishFiles?: string[],
* vitestEnvironment?: "happy-dom",
* skipTsconfigReferences?: boolean,
* aliasConsola?: boolean
* }} options
* @returns {import("@monorepolint/config").RuleModule[]}
*/
function standardPackageRules(shared, options) {
options = {
...options,
vitestEnvironment: options.vitestEnvironment
?? (options.react ? "happy-dom" : undefined),
};
return [
disallowWorkspaceCaret({ ...shared }),

Expand All @@ -349,7 +359,7 @@ function standardPackageRules(shared, options) {
customTsconfigExcludes: options.customTsconfigExcludes,
skipTsconfigReferences: options.skipTsconfigReferences,
outDir: "build/esm",
react: options.vitestEnvironment === "happy-dom",
react: options.react || options.vitestEnvironment === "happy-dom",
},
),
}),
Expand Down Expand Up @@ -443,6 +453,7 @@ function standardPackageRules(shared, options) {
"access": "public",
},
files: [
...(options.extraPublishFiles ?? []),
"build/cjs",
"build/esm",
"build/browser",
Expand Down Expand Up @@ -630,7 +641,9 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.
...standardPackageRules({
excludePackages: [
...nonStandardPackages,
...testWithHappyDomPackages,
...usesReact,
...viteApp,
...consumerCliPackages,
],
}, {
esmOnly: true,
Expand All @@ -639,35 +652,48 @@ NOTE: DO NOT EDIT THIS README BY HAND. It is generated by monorepolint.

...standardPackageRules({
includePackages: [
...testWithHappyDomPackages,
...usesReact,
],
}, {
vitestEnvironment: "happy-dom",
react: true,
esmOnly: true,
tsVersion: LATEST_TYPESCRIPT_DEP,
}),

...standardPackageRules({
includePackages: ["@osdk/foundry-sdk-generator"],
includePackages: [
...viteApp,
],
}, {
react: true,
esmOnly: true,
tsVersion: LATEST_TYPESCRIPT_DEP,
aliasConsola: true,
customTsconfigExcludes: [
"./src/generatedNoCheck/**/*",
],
extraPublishFiles: ["build/site"],
}),
fixedDepsOnly({
includePackages: ["@osdk/foundry-sdk-generator"],

packageScript({
includePackages: [...viteApp],
options: {
scripts: {
"build": "vite build",
"dev": "vite",
"preview": "vite preview",
},
},
}),

...standardPackageRules({
includePackages: ["@osdk/e2e.test.foundry-sdk-generator"],
includePackages: [
...consumerCliPackages,
],
}, {
esmOnly: true,
tsVersion: LATEST_TYPESCRIPT_DEP,
customTsconfigExcludes: [
"./src/generatedNoCheck/**/*",
aliasConsola: false,
}),
fixedDepsOnly({
includePackages: [
...consumerCliPackages,
],
}),

Expand Down
18 changes: 9 additions & 9 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"transpile": "monorepo.tool.transpile tsup"
},
"dependencies": {
"@arethetypeswrong/cli": "^0.15.2",
"ajv": "^8.13.0",
"archiver": "^7.0.1",
"consola": "^3.2.3",
"open": "^10.1.0",
"pretty-bytes": "^6.1.1",
"semver": "^7.6.3",
"tslib": "^2.6.3",
"yargs": "^17.7.2"
"@arethetypeswrong/cli": "0.15.2",
"ajv": "8.13.0",
"archiver": "7.0.1",
"consola": "3.2.3",
"open": "10.1.0",
"pretty-bytes": "6.1.1",
"semver": "7.6.3",
"tslib": "2.6.3",
"yargs": "17.7.2"
},
"devDependencies": {
"@osdk/cli.cmd.typescript": "workspace:~",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/util/streamutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function* parseStreamedResponse(
let prevChunks: Uint8Array[] = [];
let openBracesCount = 0;

for await (let chunk of asyncIterable) {
for await (const chunk of asyncIterable) {
// on the first chunk, skip the expected START_TOKEN if we see it
let i = 0;
if (!parsedStart) {
Expand Down
8 changes: 4 additions & 4 deletions packages/create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"transpile": "monorepo.tool.transpile tsup"
},
"dependencies": {
"consola": "^3.2.3",
"find-up": "^7.0.0",
"handlebars": "^4.7.8",
"yargs": "^17.7.2"
"consola": "3.2.3",
"find-up": "7.0.0",
"handlebars": "4.7.8",
"yargs": "17.7.2"
},
"devDependencies": {
"@osdk/create-app.template.expo.v2": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e.sandbox.catchall/src/loggingFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function loggingFetch(
input: RequestInfo | URL,
init?: RequestInit | undefined,
): Promise<Response> {
let url = new URL(
const url = new URL(
(typeof input === "string")
? input
: (input instanceof URL)
Expand Down
13 changes: 9 additions & 4 deletions packages/e2e.sandbox.oauth.public.react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@
"exports": {
".": {
"browser": "./build/browser/index.js",
"import": "./build/esm/index.js"
"import": "./build/esm/index.js",
"default": "./build/browser/index.js"
},
"./*": {
"browser": "./build/browser/public/*.js",
"import": "./build/esm/public/*.js"
"import": "./build/esm/public/*.js",
"default": "./build/browser/public/*.js"
}
},
"scripts": {
"build": "tsc && vite build",
"build": "vite build",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"dev": "vite",
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"preview": "vite preview"
"preview": "vite preview",
"transpile": "monorepo.tool.transpile"
},
"dependencies": {
"@osdk/client": "workspace:~",
Expand All @@ -48,6 +52,7 @@
"access": "public"
},
"files": [
"build/site",
"build/cjs",
"build/esm",
"build/browser",
Expand Down
25 changes: 25 additions & 0 deletions packages/e2e.sandbox.oauth.public.react-router/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2023 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { configDefaults, defineConfig } from "vitest/config";

export default defineConfig({
test: {
pool: "forks",
exclude: [...configDefaults.exclude, "**/build/**/*"],
environment: "happy-dom",
},
});
45 changes: 40 additions & 5 deletions packages/e2e.sandbox.todoapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,29 @@
"type": "git",
"url": "https://github.com/palantir/osdk-ts.git"
},
"exports": {
".": {
"browser": "./build/browser/index.js",
"import": "./build/esm/index.js",
"default": "./build/browser/index.js"
},
"./*": {
"browser": "./build/browser/public/*.js",
"import": "./build/esm/public/*.js",
"default": "./build/browser/public/*.js"
}
},
"scripts": {
"build": "tsc && vite build",
"codegen": "rm -rf src/generatedNoCheck2/* && osdk-unstable-typescript generate --outDir src/generatedNoCheck2 --beta --ontologyPath ontology.json --version dev --internal",
"build": "vite build",
"check-attw": "monorepo.tool.attw esm",
"check-spelling": "cspell --quiet .",
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
"codegen": "rm -rf src/generatedNoCheck2/* && osdk-unstable-typescript generate --outDir src/generatedNoCheck2 --ontologyPath ontology.json --version dev --internal --packageType module",
"dev": "vite",
"lint": "eslint .",
"preview": "vite preview"
"fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
"preview": "vite preview",
"transpile": "monorepo.tool.transpile"
},
"dependencies": {
"@osdk/api": "workspace:~",
Expand All @@ -32,6 +49,9 @@
"@arethetypeswrong/cli": "^0.15.2",
"@osdk/api": "workspace:~",
"@osdk/cli.cmd.typescript": "workspace:~",
"@osdk/monorepo.api-extractor": "workspace:~",
"@osdk/monorepo.tsconfig": "workspace:~",
"@osdk/monorepo.tsup": "workspace:~",
"@types/core-js": "^2.5.8",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.2.25",
Expand All @@ -43,9 +63,24 @@
"rollup-plugin-visualizer": "^5.12.0",
"tailwindcss": "^3.4.4",
"tslib": "^2.6.3",
"typescript": "^5.4.5",
"typescript": "~5.5.4",
"typescript-eslint": "^8.15.0",
"vite": "^5.4.8"
},
"publishConfig": {
"access": "public"
},
"files": [
"build/site",
"build/cjs",
"build/esm",
"build/browser",
"CHANGELOG.md",
"package.json",
"templates",
"*.d.ts"
],
"module": "./build/esm/index.js",
"types": "./build/esm/index.d.ts",
"type": "module"
}
7 changes: 4 additions & 3 deletions packages/e2e.sandbox.todoapp/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import "./App.css";
import CreateTodoForm from "./CreateTodoForm";
import { TodoView } from "./TodoView";
import { useTodos } from "./useTodos";
import CreateTodoForm from "./CreateTodoForm.js";
import { TodoView } from "./TodoView.js";
import { useTodos } from "./useTodos.js";

function App() {
const { todos, isLoading, toggleComplete, error, isValidating, createTodo } =
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e.sandbox.todoapp/src/TodoView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import type { SimpleTodo } from "./useTodos";
import React, { useState } from "react";
import type { SimpleTodo } from "./useTodos.js";

export function TodoView({
todo,
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e.sandbox.todoapp/src/foundryClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createClient } from "@osdk/client";
import { createPublicOauthClient } from "@osdk/oauth";
import invariant from "tiny-invariant";
import { $ontologyRid } from "./generatedNoCheck2";
import { $ontologyRid } from "./generatedNoCheck2/index.js";

invariant(
import.meta.env.VITE_FOUNDRY_CLIENT_ID,
Expand Down
18 changes: 9 additions & 9 deletions packages/e2e.sandbox.todoapp/src/generatedNoCheck2/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export { completeTodo, createTodo } from './ontology/actions';
export * as $Actions from './ontology/actions';
export {} from './ontology/interfaces';
export * as $Interfaces from './ontology/interfaces';
export { Todo } from './ontology/objects';
export * as $Objects from './ontology/objects';
export {} from './ontology/queries';
export * as $Queries from './ontology/queries';
export { $ontologyRid } from './OntologyMetadata';
export { completeTodo, createTodo } from './ontology/actions.js';
export * as $Actions from './ontology/actions.js';
export {} from './ontology/interfaces.js';
export * as $Interfaces from './ontology/interfaces.js';
export { Todo } from './ontology/objects.js';
export * as $Objects from './ontology/objects.js';
export {} from './ontology/queries.js';
export * as $Queries from './ontology/queries.js';
export { $ontologyRid } from './OntologyMetadata.js';
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { completeTodo } from './actions/completeTodo';
export { createTodo } from './actions/createTodo';
export { completeTodo } from './actions/completeTodo.js';
export { createTodo } from './actions/createTodo.js';
Loading
Loading