Skip to content

Commit

Permalink
feat: ts output to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed May 6, 2024
1 parent c850757 commit e8c8b49
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Salesforce cache
.sfdx
.sf

# Logs
logs
Expand Down Expand Up @@ -30,3 +31,6 @@ jspm_packages/

# MacOS folder atttribute tracking
**/.DS_Store

# typescript output
lib
12 changes: 0 additions & 12 deletions index.js

This file was deleted.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "@salesforce/schemas",
"version": "1.7.0",
"description": "This repository contains the spec and schema for the Scratch Org Definition Configuration file and `sfdx-project.json` file.",
"main": "index.js",
"main": "lib/index.js",
"files": [
"index.js",
"*.schema.json"
"*.schema.json",
"lib"
],
"scripts": {
"build": "ts-json-schema-generator --path src/sfdx-project/sfdxProjectJson.ts --type ProjectJson --out compiled/sfdx-project.schema.json -f tsconfig.json --no-top-ref --id http://schemas.salesforce.com/sfdx-project.json; cp compiled/sfdx-project.schema.json sfdx-project.schema.json",
"build": "tsc -p . --pretty; ts-json-schema-generator --path src/sfdx-project/sfdxProjectJson.ts --type ProjectJson --out compiled/sfdx-project.schema.json -f tsconfig.json --no-top-ref --id http://schemas.salesforce.com/sfdx-project.json; cp compiled/sfdx-project.schema.json sfdx-project.schema.json",
"features-update": "node ./scripts/update-scratch-def-features.js",
"settings-update": "node ./scripts/update-scratch-def-settings.js",
"commit-init": "commitizen init cz-conventional-changelog --save-dev --save-exact --force",
Expand All @@ -31,14 +32,16 @@
"@commitlint/cli": "^7",
"@commitlint/config-conventional": "^7",
"@salesforce/dev-config": "^3.1.0",
"@types/node": "^20.12.10",
"ajv": "^8.11.0",
"commitizen": "^3.0.5",
"cz-conventional-changelog": "^2.1.0",
"husky": "^3.0.2",
"jest": "^24.8.0",
"prettier": "^1.18.2",
"shelljs": "0.8.5",
"ts-json-schema-generator": "^1.5.1"
"ts-json-schema-generator": "^1.5.1",
"typescript": "^5.4.5"
},
"husky": {
"hooks": {
Expand All @@ -54,4 +57,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
export { ProjectJson } from "./sfdx-project/sfdxProjectJson";
import fs from "node:fs";
import path from "node:path";

export { ProjectJson } from "./sfdx-project/sfdxProjectJson";
export { PackageDir, PackageDirDependency } from "./sfdx-project/packageDir";

/** TS really doesn't want us to export things with hyphens. I tried to statically export the 2 top-level json files
* but that was throwing compiler errors. So I kept the original code from index.js to dynamically find and export the schemas.
*/
const schemas = fs
.readdirSync(__dirname)
.filter(filename => filename.endsWith("schema.json"));

for (const schema of schemas) {
exports[path.basename(schema, ".schema.json")] = path.resolve(
path.join(__dirname, schema)
);
}
7 changes: 5 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"outDir": "./lib",
"skipLibCheck": true,
"strictNullChecks": true
"strictNullChecks": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"esModuleInterop": true
},
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts", "*.schema.json"]
}
17 changes: 17 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,13 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/node@^20.12.10":
version "20.12.10"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.10.tgz#8f0c3f12b0f075eee1fe20c1afb417e9765bef76"
integrity sha512-Eem5pH9pmWBHoGAT8Dr5fdc5rYA+4NAovdM4EktRPVAAiJhmWWfQrA0cFhAbOsQdSfIHjAud6YdkbL69+zSKjw==
dependencies:
undici-types "~5.26.4"

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
Expand Down Expand Up @@ -4286,11 +4293,21 @@ type-fest@^0.6.0:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==

typescript@^5.4.5:
version "5.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.5.tgz#42ccef2c571fdbd0f6718b1d1f5e6e5ef006f611"
integrity sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==

typescript@~5.4.2:
version "5.4.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.4.tgz#eb2471e7b0a5f1377523700a21669dce30c2d952"
integrity sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

union-value@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"
Expand Down

0 comments on commit e8c8b49

Please sign in to comment.