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

[formrecognizer] Migrate @azure/ai-form-recognizer to ESM/vitest #31968

Merged
merged 23 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
205fe77
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Nov 26, 2024
efee6ca
Migration: Update test config
mpodwysocki Nov 26, 2024
b86a26c
Migration: Clean up files
mpodwysocki Nov 26, 2024
320121b
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Nov 26, 2024
dd48bd5
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Nov 26, 2024
1c5aa2c
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Nov 26, 2024
bf333fc
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Nov 26, 2024
296a5b7
Migration: Apply codemod: "addViHelper"
mpodwysocki Nov 26, 2024
134048e
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Nov 26, 2024
d74bef8
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Nov 26, 2024
e169041
Migration: rushx format
mpodwysocki Nov 26, 2024
1fc7c8d
[formrecognizer] Migrate @azure/ai-form-recognizer to ESM/vitest
mpodwysocki Nov 26, 2024
deeaeb3
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-js into…
HarshaNalluru Nov 27, 2024
8d6be95
fix header - for gen-model
HarshaNalluru Nov 27, 2024
afe2da0
lock file
HarshaNalluru Nov 27, 2024
7d77e5f
fix tests
HarshaNalluru Nov 28, 2024
aed272a
handle shebang
HarshaNalluru Nov 28, 2024
7ede80a
Merge branch 'main' of https://github.com/azure/azure-sdk-for-js into…
HarshaNalluru Dec 2, 2024
25ffc24
lock file
HarshaNalluru Dec 2, 2024
038f2db
[formrecognizer] Migrate @azure/ai-form-recognizer to ESM/vitest
mpodwysocki Dec 2, 2024
358d202
[formrecognizer] Migrate @azure/ai-form-recognizer to ESM/vitest
mpodwysocki Dec 2, 2024
6c2388a
[formrecognizer] Migrate @azure/ai-form-recognizer to ESM/vitest
mpodwysocki Dec 2, 2024
7d08322
[formrecognizer] Migrate @azure/ai-form-recognizer to ESM/vitest
mpodwysocki Dec 2, 2024
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
1,684 changes: 639 additions & 1,045 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions sdk/formrecognizer/ai-form-recognizer/.nycrc

This file was deleted.

4 changes: 2 additions & 2 deletions sdk/formrecognizer/ai-form-recognizer/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"mainEntryPointFilePath": "dist/esm/index.d.ts",
"docModel": {
"enabled": true
},
Expand All @@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/ai-form-recognizer.d.ts"
"publicTrimmedFilePath": "dist/ai-form-recognizer.d.ts"
},
"messages": {
"tsdocMessageReporting": {
Expand Down
133 changes: 0 additions & 133 deletions sdk/formrecognizer/ai-form-recognizer/karma.conf.js

This file was deleted.

93 changes: 56 additions & 37 deletions sdk/formrecognizer/ai-form-recognizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@
"cloud"
],
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist-esm/src/index.js",
"types": "./types/ai-form-recognizer.d.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/commonjs/index.d.ts",
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/formrecognizer/ai-form-recognizer/",
"repository": "github:Azure/azure-sdk-for-js",
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"files": [
"dist/",
"dist-esm/src/",
"dom-shims.d.ts",
"types/ai-form-recognizer.d.ts",
"README.md",
"LICENSE"
],
Expand All @@ -49,30 +46,28 @@
"node": ">=18.0.0"
},
"scripts": {
"build": "npm run clean && tsc -p . && dev-tool run bundle && npm run bundle:bin && dev-tool run extract-api",
"build:browser": "tsc -p . && dev-tool run bundle",
"build:node": "tsc -p . && dev-tool run bundle",
"build": "npm run clean && dev-tool run build-package && npm run bundle:bin && dev-tool run extract-api",
"build:samples": "echo Obsolete.",
"build:test": "tsc -p . && dev-tool run bundle",
"build:test": "echo Obsolete.",
"bundle:bin": "rollup -c rollup.config.bin.mjs 2>&1",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"bin/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"clean": "dev-tool run vendored rimraf --glob dist dist-* temp types *.tgz *.log test-results.*xml",
"execute:samples": "dev-tool samples run samples-dev/",
"extract-api": "tsc -p . && dev-tool run extract-api",
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"bin/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"generate:client": "autorest --typescript swagger/README.md",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:browser": "dev-tool run test:browser",
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 1200000 --exclude 'dist-esm/**/browser/*.spec.js' \"dist-esm/test/**/*.spec.js\" \"dist-esm/test/**/node/*.spec.js\"",
"integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
"integration-test:node": "dev-tool run test:vitest",
"lint": "eslint package.json api-extractor.json README.md src test",
"lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1",
"test": "npm run build:test && npm run unit-test && npm run integration-test",
"test:browser": "npm run build:test && npm run unit-test:browser",
"test:node": "npm run build:test && npm run unit-test:node",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "dev-tool run test:browser",
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' \"test/**/*.spec.ts\" \"test/**/node/*.spec.ts\"",
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped"
},
"sideEffects": false,
Expand All @@ -90,38 +85,24 @@
"tslib": "^2.2.0"
},
"devDependencies": {
"@azure-tools/test-credential": "^1.0.0",
"@azure-tools/test-recorder": "^3.0.0",
"@azure-tools/test-utils": "^1.0.1",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.0.1",
"@rollup/plugin-node-resolve": "^15.0.0",
"@types/chai": "^4.1.6",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0",
"@types/sinon": "^17.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"@vitest/browser": "^2.1.6",
"@vitest/coverage-istanbul": "^2.1.6",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^2.1.3",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"magic-string": "~0.30.10",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"playwright": "^1.49.0",
"prettier": "^3.3.3",
"rollup": "^4.0.0",
"sinon": "^17.0.0",
"ts-node": "^10.0.0",
"typescript": "~5.6.2"
"typescript": "~5.6.2",
"vitest": "^2.1.6"
},
"//sampleConfiguration": {
"skip": [
Expand Down Expand Up @@ -173,5 +154,43 @@
"javascript/assets/w2/w2-single.png"
]
}
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"browser": "./dist/browser/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
}
}
14 changes: 8 additions & 6 deletions sdk/formrecognizer/ai-form-recognizer/rollup.config.bin.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import fs from "fs";
import MagicString from "magic-string";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { chmodSync, statSync } from "node:fs";
import MagicString from "magic-string";
import nodeResolve from "@rollup/plugin-node-resolve";
import { readFile } from "fs/promises";
import { readFile } from "node:fs/promises";

// Some magic code to preserve the shebang and set the executable bit on the generated bundle.
const executable = (options = {}) => {
Expand Down Expand Up @@ -32,10 +34,10 @@ const executable = (options = {}) => {
},
writeBundle() {
if (fileName && process.platform !== "win32") {
const stat = fs.statSync(fileName);
const stat = statSync(fileName);

// chmod a+x -> 0o111
fs.chmodSync(fileName, stat.mode | 0o111);
chmodSync(fileName, stat.mode | 0o111);
}
},
};
Expand All @@ -45,7 +47,7 @@ const pkg = JSON.parse(await readFile("./package.json", { encoding: "utf-8" }));

/** @type {import('rollup').RollupOptions} */
const config = {
input: ["dist-esm/bin/gen-model.js"],
input: ["dist/esm/bin/gen-model.js"],
output: {
format: "cjs",
file: "dist-bin/gen-model.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { AzureKeyCredential, DocumentAnalysisClient } from "@azure/ai-form-recognizer";

import { PrebuiltBusinessCardModel } from "./prebuilt/prebuilt-businessCard";
import { PrebuiltBusinessCardModel } from "./prebuilt/prebuilt-businessCard.js";

import * as dotenv from "dotenv";
dotenv.config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { AzureKeyCredential, DocumentAnalysisClient } from "@azure/ai-form-recognizer";

import { PrebuiltIdDocumentModel } from "./prebuilt/prebuilt-idDocument";
import { PrebuiltIdDocumentModel } from "./prebuilt/prebuilt-idDocument.js";

import * as dotenv from "dotenv";
dotenv.config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { AzureKeyCredential, DocumentAnalysisClient } from "@azure/ai-form-recognizer";

import { PrebuiltInvoiceModel } from "./prebuilt/prebuilt-invoice";
import { PrebuiltInvoiceModel } from "./prebuilt/prebuilt-invoice.js";

import * as dotenv from "dotenv";
dotenv.config();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { AzureKeyCredential, DocumentAnalysisClient } from "@azure/ai-form-recognizer";

import { PrebuiltReceiptModel } from "./prebuilt/prebuilt-receipt";
import { PrebuiltReceiptModel } from "./prebuilt/prebuilt-receipt.js";

import * as dotenv from "dotenv";
dotenv.config();
Expand Down
Loading
Loading