@osdk/create-widget 2.0.0-beta.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/build/{browser/esm-VPCD3XBG.js → esm/esm-C6MU7DAZ.js} +104 -82
- package/build/esm/esm-C6MU7DAZ.js.map +1 -0
- package/build/esm/esm-ENH745KN.js +240 -0
- package/build/esm/esm-ENH745KN.js.map +1 -0
- package/build/esm/index.js +42 -51
- package/build/esm/index.js.map +1 -1
- package/build/{esm → types}/cli.d.ts +0 -1
- package/build/types/cli.d.ts.map +1 -0
- package/build/types/cli.test.d.ts +1 -0
- package/build/types/cli.test.d.ts.map +1 -0
- package/build/{esm → types}/consola.d.ts +0 -1
- package/build/types/consola.d.ts.map +1 -0
- package/build/types/generate/generateFoundryConfigJson.d.ts +5 -0
- package/build/types/generate/generateFoundryConfigJson.d.ts.map +1 -0
- package/build/types/generate/generateFoundryConfigJson.test.d.ts +1 -0
- package/build/types/generate/generateFoundryConfigJson.test.d.ts.map +1 -0
- package/build/types/generate/generateNpmRc.d.ts +4 -0
- package/build/types/generate/generateNpmRc.d.ts.map +1 -0
- package/build/types/generate/generateNpmRc.test.d.ts +1 -0
- package/build/types/generate/generateNpmRc.test.d.ts.map +1 -0
- package/build/{esm → types}/generatedNoCheck/templates.d.ts +0 -1
- package/build/types/generatedNoCheck/templates.d.ts.map +1 -0
- package/build/{esm → types}/getPackageFiles.d.ts +1 -2
- package/build/types/getPackageFiles.d.ts.map +1 -0
- package/build/{esm → types}/highlight.d.ts +0 -1
- package/build/types/highlight.d.ts.map +1 -0
- package/build/{esm → types}/index.d.ts +1 -2
- package/build/types/index.d.ts.map +1 -0
- package/build/types/prompts/promptFoundryUrl.d.ts +3 -0
- package/build/types/prompts/promptFoundryUrl.d.ts.map +1 -0
- package/build/types/prompts/promptFoundryUrl.test.d.ts +1 -0
- package/build/types/prompts/promptFoundryUrl.test.d.ts.map +1 -0
- package/build/types/prompts/promptOsdkPackage.d.ts +3 -0
- package/build/types/prompts/promptOsdkPackage.d.ts.map +1 -0
- package/build/types/prompts/promptOsdkPackage.test.d.ts +1 -0
- package/build/types/prompts/promptOsdkPackage.test.d.ts.map +1 -0
- package/build/types/prompts/promptOsdkRegistryUrl.d.ts +3 -0
- package/build/types/prompts/promptOsdkRegistryUrl.d.ts.map +1 -0
- package/build/types/prompts/promptOsdkRegistryUrl.test.d.ts +1 -0
- package/build/types/prompts/promptOsdkRegistryUrl.test.d.ts.map +1 -0
- package/build/types/prompts/promptOverwrite.d.ts +4 -0
- package/build/types/prompts/promptOverwrite.d.ts.map +1 -0
- package/build/types/prompts/promptOverwrite.test.d.ts +1 -0
- package/build/types/prompts/promptOverwrite.test.d.ts.map +1 -0
- package/build/types/prompts/promptProject.d.ts +3 -0
- package/build/types/prompts/promptProject.d.ts.map +1 -0
- package/build/types/prompts/promptProject.test.d.ts +1 -0
- package/build/types/prompts/promptProject.test.d.ts.map +1 -0
- package/build/types/prompts/promptSdkVersion.d.ts +5 -0
- package/build/types/prompts/promptSdkVersion.d.ts.map +1 -0
- package/build/{esm → types}/prompts/promptTemplate.d.ts +2 -3
- package/build/types/prompts/promptTemplate.d.ts.map +1 -0
- package/build/types/prompts/promptTemplate.test.d.ts +1 -0
- package/build/types/prompts/promptTemplate.test.d.ts.map +1 -0
- package/build/types/prompts/promptWidgetSetRid.d.ts +3 -0
- package/build/types/prompts/promptWidgetSetRid.d.ts.map +1 -0
- package/build/types/prompts/promptWidgetSetRid.test.d.ts +1 -0
- package/build/types/prompts/promptWidgetSetRid.test.d.ts.map +1 -0
- package/build/types/run.d.ts +13 -0
- package/build/types/run.d.ts.map +1 -0
- package/build/types/templates.d.ts +22 -0
- package/build/types/templates.d.ts.map +1 -0
- package/package.json +25 -20
- package/build/browser/esm-VPCD3XBG.js.map +0 -1
- package/build/browser/index.js +0 -432
- package/build/browser/index.js.map +0 -1
- package/build/esm/cli.d.ts.map +0 -1
- package/build/esm/cli.test.d.ts +0 -2
- package/build/esm/cli.test.d.ts.map +0 -1
- package/build/esm/consola.d.ts.map +0 -1
- package/build/esm/esm-VPCD3XBG.js +0 -365
- package/build/esm/esm-VPCD3XBG.js.map +0 -1
- package/build/esm/generate/generateFoundryConfigJson.d.ts +0 -6
- package/build/esm/generate/generateFoundryConfigJson.d.ts.map +0 -1
- package/build/esm/generate/generateFoundryConfigJson.test.d.ts +0 -2
- package/build/esm/generate/generateFoundryConfigJson.test.d.ts.map +0 -1
- package/build/esm/generate/generateNpmRc.d.ts +0 -5
- package/build/esm/generate/generateNpmRc.d.ts.map +0 -1
- package/build/esm/generate/generateNpmRc.test.d.ts +0 -2
- package/build/esm/generate/generateNpmRc.test.d.ts.map +0 -1
- package/build/esm/generatedNoCheck/templates.d.ts.map +0 -1
- package/build/esm/getPackageFiles.d.ts.map +0 -1
- package/build/esm/highlight.d.ts.map +0 -1
- package/build/esm/index.d.ts.map +0 -1
- package/build/esm/prompts/promptFoundryUrl.d.ts +0 -4
- package/build/esm/prompts/promptFoundryUrl.d.ts.map +0 -1
- package/build/esm/prompts/promptFoundryUrl.test.d.ts +0 -2
- package/build/esm/prompts/promptFoundryUrl.test.d.ts.map +0 -1
- package/build/esm/prompts/promptOsdkPackage.d.ts +0 -4
- package/build/esm/prompts/promptOsdkPackage.d.ts.map +0 -1
- package/build/esm/prompts/promptOsdkPackage.test.d.ts +0 -2
- package/build/esm/prompts/promptOsdkPackage.test.d.ts.map +0 -1
- package/build/esm/prompts/promptOsdkRegistryUrl.d.ts +0 -4
- package/build/esm/prompts/promptOsdkRegistryUrl.d.ts.map +0 -1
- package/build/esm/prompts/promptOsdkRegistryUrl.test.d.ts +0 -2
- package/build/esm/prompts/promptOsdkRegistryUrl.test.d.ts.map +0 -1
- package/build/esm/prompts/promptOverwrite.d.ts +0 -5
- package/build/esm/prompts/promptOverwrite.d.ts.map +0 -1
- package/build/esm/prompts/promptOverwrite.test.d.ts +0 -2
- package/build/esm/prompts/promptOverwrite.test.d.ts.map +0 -1
- package/build/esm/prompts/promptProject.d.ts +0 -4
- package/build/esm/prompts/promptProject.d.ts.map +0 -1
- package/build/esm/prompts/promptProject.test.d.ts +0 -2
- package/build/esm/prompts/promptProject.test.d.ts.map +0 -1
- package/build/esm/prompts/promptSdkVersion.d.ts +0 -6
- package/build/esm/prompts/promptSdkVersion.d.ts.map +0 -1
- package/build/esm/prompts/promptTemplate.d.ts.map +0 -1
- package/build/esm/prompts/promptTemplate.test.d.ts +0 -2
- package/build/esm/prompts/promptTemplate.test.d.ts.map +0 -1
- package/build/esm/prompts/promptWidgetSetRid.d.ts +0 -4
- package/build/esm/prompts/promptWidgetSetRid.d.ts.map +0 -1
- package/build/esm/prompts/promptWidgetSetRid.test.d.ts +0 -2
- package/build/esm/prompts/promptWidgetSetRid.test.d.ts.map +0 -1
- package/build/esm/run.d.ts +0 -14
- package/build/esm/run.d.ts.map +0 -1
- package/build/esm/templates.d.ts +0 -27
- package/build/esm/templates.d.ts.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SdkVersion, Template } from "./templates.js";
|
|
2
|
+
interface RunArgs {
|
|
3
|
+
project: string;
|
|
4
|
+
overwrite: boolean;
|
|
5
|
+
template: Template;
|
|
6
|
+
sdkVersion: SdkVersion;
|
|
7
|
+
foundryUrl: string;
|
|
8
|
+
widgetSet: string;
|
|
9
|
+
osdkPackage?: string;
|
|
10
|
+
osdkRegistryUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function run({ project, overwrite, template, sdkVersion, foundryUrl, widgetSet, osdkPackage, osdkRegistryUrl }: RunArgs): Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAuBA,cAAc,YAAY,gBAAiC,gBAAiB;UAElE,QAAQ;CAChB;CACA;CACA,UAAU;CACV,YAAY;CACZ;CACA;CACA;CACA;AACD;AAED,OAAO,iBAAe,IAAI,EACxB,SACA,WACA,UACA,YACA,YACA,WACA,aACA,iBACQ,EAAP,UAAU","names":[],"sources":["../../src/run.ts"],"version":3,"file":"run.d.ts"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type SdkVersion = "1.x" | "2.x";
|
|
2
|
+
export type ModuleImportFiles = Map<string, {
|
|
3
|
+
type: "base64"
|
|
4
|
+
body: string
|
|
5
|
+
} | {
|
|
6
|
+
type: "raw"
|
|
7
|
+
body: string
|
|
8
|
+
}>;
|
|
9
|
+
export interface Template {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
envPrefix: string;
|
|
13
|
+
buildDirectory: string;
|
|
14
|
+
requiresOsdk: boolean;
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
isBeta?: boolean;
|
|
17
|
+
files: { [K in SdkVersion]? : () => Promise<ModuleImportFiles> };
|
|
18
|
+
}
|
|
19
|
+
export interface TemplateContext {
|
|
20
|
+
project: string;
|
|
21
|
+
osdkPackage?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,YAAY,aAAa,QAAQ;AAEjC,YAAY,oBAAoB,YAE5B;CACA,MAAM;CACN;AACD,IACC;CACA,MAAM;CACN;AACD;AAGH,iBAAiB,SAAS;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA,UACG,KAAK,qBAAoB,QAAQ;AAErC;AAED,iBAAiB,gBAAgB;CAC/B;CACA;AACD","names":[],"sources":["../../src/templates.ts"],"version":3,"file":"templates.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/create-widget",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,25 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./build/types/index.d.ts",
|
|
15
|
+
"default": "./build/esm/index.js"
|
|
16
|
+
},
|
|
17
|
+
"default": "./build/esm/index.js"
|
|
16
18
|
},
|
|
17
19
|
"./*": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./build/types/public/*.d.ts",
|
|
22
|
+
"default": "./build/esm/public/*.js"
|
|
23
|
+
},
|
|
24
|
+
"default": "./build/esm/public/*.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"dependencies": {
|
|
24
|
-
"consola": "
|
|
25
|
-
"find-up": "
|
|
26
|
-
"handlebars": "
|
|
27
|
-
"yargs": "
|
|
28
|
+
"consola": "3.2.3",
|
|
29
|
+
"find-up": "7.0.0",
|
|
30
|
+
"handlebars": "4.7.8",
|
|
31
|
+
"yargs": "17.7.2"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
30
34
|
"@types/node": "^18.0.0",
|
|
@@ -34,11 +38,11 @@
|
|
|
34
38
|
"redent": "^4.0.0",
|
|
35
39
|
"tmp": "^0.2.3",
|
|
36
40
|
"typescript": "~5.5.4",
|
|
37
|
-
"@osdk/create-widget.template.react.v2": "2.0.0
|
|
38
|
-
"@osdk/generator-utils": "2.1.0
|
|
39
|
-
"@osdk/monorepo.
|
|
40
|
-
"@osdk/
|
|
41
|
-
"@osdk/monorepo.
|
|
41
|
+
"@osdk/create-widget.template.minimal-react.v2": "2.0.0",
|
|
42
|
+
"@osdk/generator-utils": "2.1.0",
|
|
43
|
+
"@osdk/monorepo.api-extractor": "~0.0.0",
|
|
44
|
+
"@osdk/create-widget.template.react.v2": "2.0.0",
|
|
45
|
+
"@osdk/monorepo.tsconfig": "~0.0.0"
|
|
42
46
|
},
|
|
43
47
|
"publishConfig": {
|
|
44
48
|
"access": "public"
|
|
@@ -47,9 +51,8 @@
|
|
|
47
51
|
"create-osdk-widget": "bin/createWidget.mjs"
|
|
48
52
|
},
|
|
49
53
|
"files": [
|
|
50
|
-
"build/cjs",
|
|
51
54
|
"build/esm",
|
|
52
|
-
"build/
|
|
55
|
+
"build/types",
|
|
53
56
|
"CHANGELOG.md",
|
|
54
57
|
"package.json",
|
|
55
58
|
"templates",
|
|
@@ -59,7 +62,7 @@
|
|
|
59
62
|
"types": "./build/esm/index.d.ts",
|
|
60
63
|
"type": "module",
|
|
61
64
|
"scripts": {
|
|
62
|
-
"check-attw": "
|
|
65
|
+
"check-attw": "attw --profile esm-only --pack .",
|
|
63
66
|
"check-spelling": "cspell --quiet .",
|
|
64
67
|
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
|
|
65
68
|
"codegen": "node codegen.mjs",
|
|
@@ -67,6 +70,8 @@
|
|
|
67
70
|
"lint": "eslint . && dprint check --config $(find-up dprint.json)",
|
|
68
71
|
"test": "vitest run --pool=forks",
|
|
69
72
|
"test:watch": "vitest",
|
|
70
|
-
"
|
|
73
|
+
"transpileEsm": "monorepo.tool.transpile -f esm -m bundle -t node",
|
|
74
|
+
"transpileTypes": "monorepo.tool.transpile -f esm -m types -t node",
|
|
75
|
+
"typecheck": "tsc --noEmit --emitDeclarationOnly false"
|
|
71
76
|
}
|
|
72
77
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../create-widget.template.react.v2/build/esm/generatedNoCheck/index.js"],"names":[],"mappings":"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","file":"esm-VPCD3XBG.js","sourcesContent":["export const files = new Map([[\"README.md.hbs\", {\n type: \"raw\",\n body: `# {{project}}\n\nThis project was generated with [\\`@osdk/create-widget\\`](https://www.npmjs.com/package/@osdk/create-widget) and demonstrates developing a custom widget to be embedded within Foundry UIs such as Workshop. It uses the Ontology SDK package \\`{{osdkPackage}}\\` with React on top of Vite. Check out the [Vite](https://vitejs.dev/guide/) docs for further configuration.\n\n## Developing\n\nRun the following command or equivalent with your preferred package manager to start a local development server on \\`http://localhost:8080\\`:\n\n\\`\\`\\`sh\nnpm run dev\n\\`\\`\\`\n\nDevelopment configuration is stored in \\`.env.development\\`.\n\n## Deploying\n\nRun the following command or equivalent with your preferred package manager to create a production build of your application:\n\n\\`\\`\\`sh\nnpm run build\n\\`\\`\\`\n\nProduction configuration is stored in \\`.env.production\\`.\n\nA \\`foundry.config.json\\` file is included in the root of this project to make deploying to Foundry website hosting with [\\`@osdk/cli\\`](https://www.npmjs.com/package/@osdk/cli) easier. If you are not using Foundry website hosting for your application you may delete this file.\n`\n}], [\".gitignore\", {\n type: \"raw\",\n body: `# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\npnpm-debug.log*\nlerna-debug.log*\n\nnode_modules\ndist\ndist-ssr\n*.local\n\n# Editor directories and files\n.vscode/*\n!.vscode/extensions.json\n.idea\n.DS_Store\n*.suo\n*.ntvs*\n*.njsproj\n*.sln\n*.sw?\n`\n}], [\"eslint.config.mjs\", {\n \"type\": \"base64\",\n \"body\": \"Ly8gQHRzLWNoZWNrCmltcG9ydCBlc2xpbnQgZnJvbSAiQGVzbGludC9qcyI7CmltcG9ydCB0c1BhcnNlciBmcm9tICJAdHlwZXNjcmlwdC1lc2xpbnQvcGFyc2VyIjsKaW1wb3J0ICogYXMgaW1wb3J0UGx1Z2luIGZyb20gImVzbGludC1wbHVnaW4taW1wb3J0IjsKaW1wb3J0IGpzeEExMXlQbHVnaW4gZnJvbSAiZXNsaW50LXBsdWdpbi1qc3gtYTExeSI7CmltcG9ydCByZWFjdFBsdWdpbiBmcm9tICJlc2xpbnQtcGx1Z2luLXJlYWN0IjsKaW1wb3J0IHJlYWN0SG9va3NQbHVnaW4gZnJvbSAiZXNsaW50LXBsdWdpbi1yZWFjdC1ob29rcyI7CmltcG9ydCByZWFjdFJlZnJlc2ggZnJvbSAiZXNsaW50LXBsdWdpbi1yZWFjdC1yZWZyZXNoIjsKaW1wb3J0IGdsb2JhbHMgZnJvbSAiZ2xvYmFscyI7CmltcG9ydCB0c2VzbGludCBmcm9tICJ0eXBlc2NyaXB0LWVzbGludCI7CgpleHBvcnQgZGVmYXVsdCB0c2VzbGludC5jb25maWcoewogIGZpbGVzOiBbImVzbGludC5jb25maWcubWpzIiwgInNyYy8qKi8qLntqcyxtanMsY2pzLHRzLGpzeCx0c3h9Il0sCiAgc2V0dGluZ3M6IHsKICAgIHJlYWN0OiB7CiAgICAgIHZlcnNpb246ICJkZXRlY3QiLAogICAgfSwKCiAgICAiaW1wb3J0L3Jlc29sdmVyIjogewogICAgICBub2RlOiB7CiAgICAgICAgZXh0ZW5zaW9uczogWyIuanMiLCAiLmpzeCIsICIudHMiLCAiLnRzeCJdLAogICAgICB9LAogICAgfSwKICB9LAogIGxhbmd1YWdlT3B0aW9uczogewogICAgZ2xvYmFsczogewogICAgICAuLi5nbG9iYWxzLmJyb3dzZXIsCiAgICB9LAoKICAgIHBhcnNlcjogdHNQYXJzZXIsCiAgfSwKICBleHRlbmRzOiBbCiAgICBlc2xpbnQuY29uZmlncy5yZWNvbW1lbmRlZCwKICAgIC4uLnRzZXNsaW50LmNvbmZpZ3MucmVjb21tZW5kZWQsCiAgXSwKICBwbHVnaW5zOiB7CiAgICAicmVhY3QiOiAvKiogQHR5cGUgaW1wb3J0KCJlc2xpbnQiKS5FU0xpbnQuUGx1Z2luICovIChyZWFjdFBsdWdpbiksCiAgICAicmVhY3QtcmVmcmVzaCI6IHJlYWN0UmVmcmVzaCwKICAgICJyZWFjdC1ob29rcyI6CiAgICAgIC8qKiBAdHlwZSBpbXBvcnQoImVzbGludCIpLkVTTGludC5QbHVnaW4gKi8gKHJlYWN0SG9va3NQbHVnaW4pLAogICAgImpzeC1hMTF5IjoganN4QTExeVBsdWdpbiwKICAgICJpbXBvcnQiOiBpbXBvcnRQbHVnaW4sCiAgfSwKICBydWxlczogewogICAgLi4uKAogICAgICAvKiogQHR5cGUgaW1wb3J0KCJlc2xpbnQiKS5MaW50ZXIuUnVsZXNSZWNvcmQgKi8KICAgICAgKHJlYWN0UGx1Z2luLmNvbmZpZ3MuZmxhdD8ucmVjb21tZW5kZWQucnVsZXMpCiAgICApLAogICAgInJlYWN0LWhvb2tzL3J1bGVzLW9mLWhvb2tzIjogImVycm9yIiwKICAgICJyZWFjdC1ob29rcy9leGhhdXN0aXZlLWRlcHMiOiAid2FybiIsCiAgICAuLi5qc3hBMTF5UGx1Z2luLmNvbmZpZ3MucmVjb21tZW5kZWQucnVsZXMsCiAgICAicmVhY3QtcmVmcmVzaC9vbmx5LWV4cG9ydC1jb21wb25lbnRzIjogWyJ3YXJuIiwgewogICAgICBhbGxvd0NvbnN0YW50RXhwb3J0OiB0cnVlLAogICAgfV0sCgogICAgImltcG9ydC9uYW1lZCI6ICJlcnJvciIsCiAgICAiaW1wb3J0L2RlZmF1bHQiOiAiZXJyb3IiLAogICAgImltcG9ydC9uYW1lc3BhY2UiOiAiZXJyb3IiLAogICAgImltcG9ydC9uby1kdXBsaWNhdGVzIjogImVycm9yIiwKICAgICJpbXBvcnQvbm8tZXh0cmFuZW91cy1kZXBlbmRlbmNpZXMiOiAiZXJyb3IiLAoKICAgICJyZWFjdC9yZWFjdC1pbi1qc3gtc2NvcGUiOiAib2ZmIiwKICB9LAp9KTsK\"\n}], [\"index.html\", {\n type: \"raw\",\n body: `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Widget: Ontology SDK + React</title>\n </head>\n <body>\n <script type=\"module\" src=\"/src/main.tsx\"></script>\n </body>\n</html>\n`\n}], [\"package.json.hbs\", {\n type: \"raw\",\n body: `{\n \"name\": \"{{project}}\",\n \"private\": true,\n \"version\": \"0.0.0\",\n \"type\": \"module\",\n \"scripts\": {\n \"dev\": \"vite\",\n \"build\": \"tsc && vite build\",\n \"lint\": \"eslint . --report-unused-disable-directives --max-warnings 0\",\n \"test\": \"vitest run --passWithNoTests\",\n \"preview\": \"vite preview\"\n },\n \"dependencies\": {\n \"{{osdkPackage}}\": \"latest\",\n \"@osdk/client\": \"^2.0.0\",\n \"@osdk/widget-client-react.unstable\": \"^1.0.0\",\n \"@osdk/widget-client.unstable\": \"^1.0.0\",\n \"@radix-ui/react-icons\": \"^1.3.1\",\n \"@radix-ui/themes\": \"^3.1.4\",\n \"react\": \"^18\",\n \"react-dom\": \"^18\",\n \"react-router-dom\": \"^6.23.1\"\n },\n \"devDependencies\": {\n \"@osdk/widget.vite-plugin.unstable\": \"^1.0.0\",\n \"@eslint/compat\": \"^1.2.1\",\n \"@eslint/js\": \"^9.13.0\",\n \"@types/react\": \"^18\",\n \"@types/react-dom\": \"^18\",\n \"@typescript-eslint/eslint-plugin\": \"^8.11.0\",\n \"@typescript-eslint/parser\": \"^8.11.0\",\n \"@vitejs/plugin-react\": \"^4.2.0\",\n \"eslint\": \"^9.13.0\",\n \"eslint-plugin-import\": \"^2.31.0\",\n \"eslint-plugin-jsx-a11y\": \"^6.10.1\",\n \"eslint-plugin-react\": \"^7.37.2\",\n \"eslint-plugin-react-hooks\": \"^5.0.0\",\n \"eslint-plugin-react-refresh\": \"^0.4.14\",\n \"globals\": \"^15.11.0\",\n \"typescript\": \"~5.5.4\",\n \"typescript-eslint\": \"^8.11.0\",\n \"vite\": \"^6.0.11\",\n \"vitest\": \"^3.0.4\"\n }\n}`\n}], [\"src/context.ts\", {\n \"type\": \"base64\",\n \"body\": \"aW1wb3J0IHsgdXNlRm91bmRyeVdpZGdldENvbnRleHQgfSBmcm9tICJAb3Nkay93aWRnZXQtY2xpZW50LXJlYWN0LnVuc3RhYmxlIjsKaW1wb3J0IHR5cGUgTWFpbkNvbmZpZyBmcm9tICIuL21haW4uY29uZmlnLmpzIjsKCmV4cG9ydCBjb25zdCB1c2VXaWRnZXRDb250ZXh0ID0gdXNlRm91bmRyeVdpZGdldENvbnRleHQud2l0aFR5cGVzPAogIHR5cGVvZiBNYWluQ29uZmlnCj4oKTsK\"\n}], [\"src/main.config.ts.hbs\", {\n type: \"raw\",\n body: `import { defineConfig } from \"@osdk/widget-client.unstable\";\n\nexport default defineConfig({\n id: \"widgetId\",\n name: \"Custom Widget\",\n description: \"And example custom widget implementation\",\n type: \"workshop\",\n parameters: {\n headerText: {\n displayName: \"Widget title\",\n type: \"string\",\n },\n todoItems: {\n displayName: \"Todo items\",\n type: \"array\",\n subType: \"string\",\n },\n },\n events: {\n updateHeader: {\n displayName: \"Update header\",\n parameterUpdateIds: [\"headerText\"],\n },\n updateTodoItems: {\n displayName: \"Update todo items\",\n parameterUpdateIds: [\"todoItems\"],\n },\n },\n});\n`\n}], [\"src/main.css\", {\n \"type\": \"base64\",\n \"body\": \"\"\n}], [\"src/main.tsx\", {\n type: \"raw\",\n body: `import \"@radix-ui/themes/styles.css\";\nimport \"./main.css\";\n\nimport { FoundryWidget } from \"@osdk/widget-client-react.unstable\";\nimport { Theme } from \"@radix-ui/themes\";\nimport { createRoot } from \"react-dom/client\";\nimport MainConfig from \"./main.config.js\";\nimport { App } from \"./widget.js\";\n\nconst root = document.querySelector(\"body\")!;\n\ncreateRoot(root).render(\n <Theme>\n <FoundryWidget config={MainConfig}>\n <App />\n </FoundryWidget>\n </Theme>,\n);\n`\n}], [\"src/vite-env.d.ts\", {\n \"type\": \"base64\",\n \"body\": \"Ly8vIDxyZWZlcmVuY2UgdHlwZXM9InZpdGUvY2xpZW50IiAvPgo=\"\n}], [\"src/widget.tsx.hbs\", {\n type: \"raw\",\n body: `import { \\$Actions, \\$Objects, \\$Queries } from \"{{osdkPackage}}\";\nimport {\n Box,\n Button,\n Checkbox,\n Container,\n Flex,\n Heading,\n Skeleton,\n Table,\n Text,\n TextField,\n} from \"@radix-ui/themes\";\nimport React, { useCallback, useState } from \"react\";\nimport { useWidgetContext } from \"./context.js\";\n\nexport const App: React.FC = () => {\n const { parameters, emitEvent } = useWidgetContext();\n const { headerText, todoItems } = parameters.values;\n const [newTodoItem, setNewTodoItem] = useState(\"\");\n\n const handleAddTodoItem = useCallback(() => {\n emitEvent(\"updateTodoItems\", {\n parameterUpdates: {\n todoItems: [...(todoItems ?? []), newTodoItem],\n },\n });\n setNewTodoItem(\"\");\n }, [emitEvent, newTodoItem, todoItems]);\n\n const handleNewTodoItemChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setNewTodoItem(event.target.value);\n },\n []\n );\n\n const objectApiNames = Object.keys(\\$Objects);\n const actionApiNames = Object.keys(\\$Actions);\n const queryApiNames = Object.keys(\\$Queries);\n\n return (\n <Box>\n <Container size=\"1\">\n <Flex direction=\"column\" gap=\"4\">\n <Flex p=\"5\" direction=\"column\" gap=\"2\">\n <Heading size=\"4\">\n {parameters.state === \"loading\"\n || parameters.state === \"not-started\"\n ? <Skeleton>Hello, world!</Skeleton>\n : headerText ?? \"{{project}}\"}\n </Heading>\n\n <Table.Root>\n <Table.Header>\n <Table.Row>\n <Table.ColumnHeaderCell>Finished</Table.ColumnHeaderCell>\n <Table.ColumnHeaderCell>Item</Table.ColumnHeaderCell>\n </Table.Row>\n </Table.Header>\n\n <Table.Body>\n {(parameters.state === \"loading\"\n || parameters.state === \"not-started\") && (\n <>\n <Table.Row>\n <Table.Cell>\n <Skeleton>\n <Checkbox />\n </Skeleton>\n </Table.Cell>\n <Table.Cell>\n <Skeleton>Loading cell</Skeleton>\n </Table.Cell>\n </Table.Row>\n <Table.Row>\n <Table.Cell>\n <Skeleton>\n <Checkbox />\n </Skeleton>\n </Table.Cell>\n <Table.Cell>\n <Skeleton>Loading cell</Skeleton>\n </Table.Cell>\n </Table.Row>\n </>\n )}\n {parameters.state === \"loaded\"\n && todoItems?.map((item, index) => (\n <Table.Row key={index}>\n <Table.Cell>\n <Checkbox />\n </Table.Cell>\n <Table.Cell>{item}</Table.Cell>\n </Table.Row>\n ))}\n {parameters.state === \"loaded\"\n && (todoItems ?? []).length === 0 && (\n <Table.Row>\n <Table.Cell colSpan={2}>No items yet</Table.Cell>\n </Table.Row>\n )}\n <Table.Row>\n <Table.Cell colSpan={2}>\n <Flex gap=\"2\">\n <TextField.Root\n value={newTodoItem}\n onChange={handleNewTodoItemChange}\n size=\"2\"\n placeholder=\"Add item…\"\n />\n <Button onClick={handleAddTodoItem}>Add item</Button>\n </Flex>\n </Table.Cell>\n </Table.Row>\n </Table.Body>\n </Table.Root>\n\n </Flex>\n <Box>\n <Flex direction=\"column\" gap=\"2\">\n <Text>\n Try and of the following methods from your Ontology SDK\n </Text>\n <Flex direction=\"column\" gap=\"1\">\n <Heading size=\"4\">Objects ({objectApiNames.length})</Heading>\n <pre>\n {objectApiNames.map((objectApiName) => (\n <div key={objectApiName}>client({objectApiName})</div>\n ))}\n </pre>\n </Flex>\n <Flex direction=\"column\" gap=\"1\">\n <Heading size=\"4\">Actions ({actionApiNames.length})</Heading>\n <pre>\n {actionApiNames.map((actionApiName) => (\n <div key={actionApiName}>client({actionApiName})</div>\n ))}\n </pre>\n </Flex>\n <Flex direction=\"column\" gap=\"1\">\n <Heading size=\"4\">Queries ({queryApiNames.length})</Heading>\n <pre>\n {queryApiNames.map((queryApiName) => (\n <div key={queryApiName}>client({queryApiName})</div>\n ))}\n </pre>\n </Flex>\n </Flex>\n </Box>\n </Flex>\n </Container>\n </Box>\n );\n};\n`\n}], [\"tsconfig.json\", {\n \"type\": \"base64\",\n \"body\": \"ewogICJjb21waWxlck9wdGlvbnMiOiB7CiAgICAidGFyZ2V0IjogIkVTMjAyMCIsCiAgICAidXNlRGVmaW5lRm9yQ2xhc3NGaWVsZHMiOiB0cnVlLAogICAgImxpYiI6IFsiRVMyMDIwIiwgIkRPTSIsICJET00uSXRlcmFibGUiXSwKICAgICJtb2R1bGUiOiAiRVNOZXh0IiwKICAgICJza2lwTGliQ2hlY2siOiB0cnVlLAoKICAgIC8qIEJ1bmRsZXIgbW9kZSAqLwogICAgIm1vZHVsZVJlc29sdXRpb24iOiAiYnVuZGxlciIsCiAgICAiYWxsb3dJbXBvcnRpbmdUc0V4dGVuc2lvbnMiOiB0cnVlLAogICAgInJlc29sdmVKc29uTW9kdWxlIjogdHJ1ZSwKICAgICJpc29sYXRlZE1vZHVsZXMiOiB0cnVlLAogICAgIm5vRW1pdCI6IHRydWUsCiAgICAianN4IjogInJlYWN0LWpzeCIsCgogICAgLyogTGludGluZyAqLwogICAgInN0cmljdCI6IHRydWUsCiAgICAibm9VbnVzZWRMb2NhbHMiOiB0cnVlLAogICAgIm5vVW51c2VkUGFyYW1ldGVycyI6IHRydWUsCiAgICAibm9GYWxsdGhyb3VnaENhc2VzSW5Td2l0Y2giOiB0cnVlCiAgfSwKICAiaW5jbHVkZSI6IFsic3JjIl0sCiAgInJlZmVyZW5jZXMiOiBbeyAicGF0aCI6ICIuL3RzY29uZmlnLm5vZGUuanNvbiIgfV0KfQo=\"\n}], [\"tsconfig.node.json\", {\n \"type\": \"base64\",\n \"body\": \"ewogICJjb21waWxlck9wdGlvbnMiOiB7CiAgICAiY29tcG9zaXRlIjogdHJ1ZSwKICAgICJza2lwTGliQ2hlY2siOiB0cnVlLAogICAgIm1vZHVsZSI6ICJFU05leHQiLAogICAgIm1vZHVsZVJlc29sdXRpb24iOiAiYnVuZGxlciIsCiAgICAiYWxsb3dTeW50aGV0aWNEZWZhdWx0SW1wb3J0cyI6IHRydWUKICB9LAogICJpbmNsdWRlIjogWyJ2aXRlLmNvbmZpZy50cyJdCn0K\"\n}], [\"vite.config.ts.hbs\", {\n type: \"raw\",\n body: `import widgetManifestPlugin from \"@osdk/widget.vite-plugin.unstable\";\nimport react from \"@vitejs/plugin-react\";\nimport { defineConfig } from \"vite\";\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n plugins: [react(), widgetManifestPlugin()],\n server: {\n port: 8080,\n },\n});\n`\n}]]);"]}
|
package/build/browser/index.js
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
import yargs from 'yargs';
|
|
2
|
-
import { hideBin } from 'yargs/helpers';
|
|
3
|
-
import { createConsola, consola as consola$1 } from 'consola';
|
|
4
|
-
import { colorize } from 'consola/utils';
|
|
5
|
-
import fs2 from 'fs';
|
|
6
|
-
import path2 from 'path';
|
|
7
|
-
import { findUpSync } from 'find-up';
|
|
8
|
-
import Handlebars from 'handlebars';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
|
|
11
|
-
// src/cli.ts
|
|
12
|
-
var consola = createConsola({
|
|
13
|
-
// https://github.com/unjs/consola/issues/251
|
|
14
|
-
async prompt(...params) {
|
|
15
|
-
const response = await consola$1.prompt(...params);
|
|
16
|
-
if (typeof response === "symbol" && response.toString() === "Symbol(clack:cancel)") {
|
|
17
|
-
consola$1.fail("Operation cancelled");
|
|
18
|
-
process.exit(0);
|
|
19
|
-
}
|
|
20
|
-
return response;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
function green(text) {
|
|
24
|
-
return colorize("green", text);
|
|
25
|
-
}
|
|
26
|
-
function italic(text) {
|
|
27
|
-
return colorize("italic", text);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/prompts/promptFoundryUrl.ts
|
|
31
|
-
async function promptFoundryUrl({
|
|
32
|
-
foundryUrl
|
|
33
|
-
}) {
|
|
34
|
-
while (foundryUrl == null || !foundryUrl.startsWith("https://")) {
|
|
35
|
-
if (foundryUrl != null) {
|
|
36
|
-
consola.fail("Please enter a valid Foundry URL");
|
|
37
|
-
}
|
|
38
|
-
foundryUrl = await consola.prompt(`Enter the URL for your Foundry stack:
|
|
39
|
-
${italic("(Example: https://example.palantirfoundry.com)")}`, {
|
|
40
|
-
type: "text"
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return foundryUrl.replace(/\/$/, "");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/prompts/promptOsdkPackage.ts
|
|
47
|
-
async function promptOsdkPackage({
|
|
48
|
-
osdkPackage
|
|
49
|
-
}) {
|
|
50
|
-
while (osdkPackage == null || !/^@[a-z0-9-]+\/sdk$/.test(osdkPackage)) {
|
|
51
|
-
if (osdkPackage != null) {
|
|
52
|
-
consola.fail("Please enter a valid OSDK package name");
|
|
53
|
-
}
|
|
54
|
-
osdkPackage = await consola.prompt(`Enter the OSDK package name for your widget set:
|
|
55
|
-
${italic("(Example: @my-widget/sdk)")}`, {
|
|
56
|
-
type: "text"
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return osdkPackage;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/prompts/promptOsdkRegistryUrl.ts
|
|
63
|
-
async function promptOsdkRegistryUrl({
|
|
64
|
-
osdkRegistryUrl
|
|
65
|
-
}) {
|
|
66
|
-
while (osdkRegistryUrl == null || !/^https:\/\/[^/]+\/artifacts\/api\/repositories\/ri\.[^/]+\/contents\/release\/npm\/?$/.test(osdkRegistryUrl)) {
|
|
67
|
-
if (osdkRegistryUrl != null) {
|
|
68
|
-
consola.fail("Please enter a valid NPM registry URL to install your OSDK package");
|
|
69
|
-
}
|
|
70
|
-
osdkRegistryUrl = await consola.prompt(`Enter the NPM registry URL to install your OSDK package:
|
|
71
|
-
${italic("(Example: https://example.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.main.repository.a4a7fe1c-486f-4226-b706-7b90005f527d/contents/release/npm)")}`, {
|
|
72
|
-
type: "text"
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return osdkRegistryUrl.replace(/\/$/, "");
|
|
76
|
-
}
|
|
77
|
-
async function promptOverwrite({
|
|
78
|
-
project,
|
|
79
|
-
overwrite
|
|
80
|
-
}) {
|
|
81
|
-
if (overwrite != null) {
|
|
82
|
-
return overwrite;
|
|
83
|
-
}
|
|
84
|
-
if (!fs2.existsSync(path2.join(process.cwd(), project))) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
const result = await consola.prompt(
|
|
88
|
-
`The directory ${green(project)} already exists do you want to overwrite or ignore it?`,
|
|
89
|
-
{
|
|
90
|
-
type: "select",
|
|
91
|
-
options: [{
|
|
92
|
-
label: "Remove existing files and continue",
|
|
93
|
-
value: "overwrite"
|
|
94
|
-
}, {
|
|
95
|
-
label: "Ignore files and continue",
|
|
96
|
-
value: "ignore"
|
|
97
|
-
}, {
|
|
98
|
-
label: "Cancel",
|
|
99
|
-
value: "cancel"
|
|
100
|
-
}]
|
|
101
|
-
}
|
|
102
|
-
// Types for "select" are wrong the value is returned rather than the option object
|
|
103
|
-
// https://github.com/unjs/consola/pull/238
|
|
104
|
-
);
|
|
105
|
-
switch (result) {
|
|
106
|
-
case "overwrite":
|
|
107
|
-
return true;
|
|
108
|
-
case "ignore":
|
|
109
|
-
return false;
|
|
110
|
-
case "cancel":
|
|
111
|
-
consola.fail("Operation cancelled");
|
|
112
|
-
process.exit(0);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/prompts/promptProject.ts
|
|
117
|
-
async function promptProject({
|
|
118
|
-
project
|
|
119
|
-
}) {
|
|
120
|
-
while (project == null || !/^[a-zA-Z0-9-_]+$/.test(project)) {
|
|
121
|
-
if (project != null) {
|
|
122
|
-
consola.fail("Project name can only contain alphanumeric characters, hyphens and underscores");
|
|
123
|
-
}
|
|
124
|
-
project = await consola.prompt("Project name:", {
|
|
125
|
-
type: "text",
|
|
126
|
-
placeholder: "my-osdk-widget",
|
|
127
|
-
default: "my-osdk-widget"
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return project;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/prompts/promptSdkVersion.ts
|
|
134
|
-
async function promptSdkVersion({
|
|
135
|
-
sdkVersion,
|
|
136
|
-
template
|
|
137
|
-
}) {
|
|
138
|
-
if (sdkVersion == null) {
|
|
139
|
-
return Object.keys(template.files)[0];
|
|
140
|
-
}
|
|
141
|
-
if (template.files[sdkVersion] == null) {
|
|
142
|
-
consola.fail(`The ${template.label} template does not support a "${sdkVersion}" SDK version.`);
|
|
143
|
-
sdkVersion = await consola.prompt(
|
|
144
|
-
`Please choose which version of the OSDK you'd like to use for the ${template.label} template:`,
|
|
145
|
-
{
|
|
146
|
-
type: "select",
|
|
147
|
-
options: Object.keys(template.files).reverse().map((sdkVersion2) => ({
|
|
148
|
-
label: sdkVersion2,
|
|
149
|
-
value: sdkVersion2
|
|
150
|
-
}))
|
|
151
|
-
}
|
|
152
|
-
// Types for "select" are wrong the value is returned rather than the option object
|
|
153
|
-
// https://github.com/unjs/consola/pull/238
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
return sdkVersion;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/getPackageFiles.ts
|
|
160
|
-
var getPackageFiles = (importPromise) => async () => (await importPromise).files;
|
|
161
|
-
|
|
162
|
-
// src/generatedNoCheck/templates.ts
|
|
163
|
-
var TEMPLATES = [
|
|
164
|
-
// React
|
|
165
|
-
{
|
|
166
|
-
id: "template-widget-react",
|
|
167
|
-
label: "React",
|
|
168
|
-
envPrefix: "VITE_",
|
|
169
|
-
buildDirectory: "./dist",
|
|
170
|
-
files: {
|
|
171
|
-
"2.x": getPackageFiles(import('./esm-VPCD3XBG.js'))
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
// src/prompts/promptTemplate.ts
|
|
177
|
-
async function promptTemplate(parsed) {
|
|
178
|
-
let useBeta = parsed.beta ?? false;
|
|
179
|
-
let template = TEMPLATES.find((t) => t.id === parsed.template || t.id === `template-${parsed.template}`);
|
|
180
|
-
if (template == null) {
|
|
181
|
-
const availableTemplates = TEMPLATES.filter((template2) => !template2.hidden && (useBeta ? template2.isBeta === true : !template2.isBeta));
|
|
182
|
-
if (availableTemplates.length === 0) {
|
|
183
|
-
throw new Error("No available templates found for the selected options.");
|
|
184
|
-
}
|
|
185
|
-
const templateId = await consola.prompt(parsed.template != null ? `The provided template ${green(parsed.template)} is invalid please select a framework:` : "Select a framework:", {
|
|
186
|
-
type: "select",
|
|
187
|
-
options: availableTemplates.map((template2) => ({
|
|
188
|
-
value: template2.id,
|
|
189
|
-
label: template2.label
|
|
190
|
-
}))
|
|
191
|
-
// Types for "select" are wrong the value is returned rather than the option object
|
|
192
|
-
// https://github.com/unjs/consola/pull/238
|
|
193
|
-
});
|
|
194
|
-
template = TEMPLATES.find((t) => t.id === templateId);
|
|
195
|
-
if (template == null) {
|
|
196
|
-
throw new Error(`Template ${templateId} should be found`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return template;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// src/prompts/promptWidgetSetRid.ts
|
|
203
|
-
async function promptWidgetSetRid({
|
|
204
|
-
widgetSetRid
|
|
205
|
-
}) {
|
|
206
|
-
while (widgetSetRid == null || !/^ri\.widgetregistry\.\.widget-set\.[^.]+$/.test(widgetSetRid)) {
|
|
207
|
-
if (widgetSetRid != null) {
|
|
208
|
-
consola.fail("Please enter a valid widget resource identifier (rid)");
|
|
209
|
-
}
|
|
210
|
-
widgetSetRid = await consola.prompt(`Enter the resource identifier (rid) for your widget set:
|
|
211
|
-
${italic("(Example: ri.widgetregistry..widget-set.1c66b352-4e00-40d2-995d-061c9d533ace)")}`, {
|
|
212
|
-
type: "text"
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
return widgetSetRid;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// ../generator-utils/build/esm/changeVersionPrefix.js
|
|
219
|
-
function changeVersionPrefix(version, prefix) {
|
|
220
|
-
const isWorkspaceProtocol = version.startsWith("workspace:");
|
|
221
|
-
if (isWorkspaceProtocol) {
|
|
222
|
-
version = version.slice("workspace:".length);
|
|
223
|
-
}
|
|
224
|
-
if (version[0] === "^" || version[0] === "~" || version[0] === "*") {
|
|
225
|
-
version = version.slice(1);
|
|
226
|
-
}
|
|
227
|
-
return `${isWorkspaceProtocol ? "workspace:" : ""}${prefix}${version}`;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// ../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
231
|
-
process.env.NODE_ENV === "production";
|
|
232
|
-
|
|
233
|
-
// src/generate/generateFoundryConfigJson.ts
|
|
234
|
-
function generateFoundryConfigJson({
|
|
235
|
-
foundryUrl,
|
|
236
|
-
widgetSetRid,
|
|
237
|
-
directory
|
|
238
|
-
}) {
|
|
239
|
-
return JSON.stringify({
|
|
240
|
-
foundryUrl,
|
|
241
|
-
widgetSet: {
|
|
242
|
-
rid: widgetSetRid,
|
|
243
|
-
directory,
|
|
244
|
-
autoVersion: {
|
|
245
|
-
type: "git-describe",
|
|
246
|
-
tagPrefix: ""
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}, null, 2) + "\n";
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// src/generate/generateNpmRc.ts
|
|
253
|
-
function generateNpmRc({
|
|
254
|
-
osdkPackage,
|
|
255
|
-
osdkRegistryUrl
|
|
256
|
-
}) {
|
|
257
|
-
const withTrailingSlash = osdkRegistryUrl.endsWith("/") ? osdkRegistryUrl : osdkRegistryUrl + "/";
|
|
258
|
-
const withoutProtocol = withTrailingSlash.replace(/^https:\/\//, "");
|
|
259
|
-
const packageScope = osdkPackage.split("/")[0];
|
|
260
|
-
return `//${withoutProtocol}:_authToken=\${FOUNDRY_TOKEN}
|
|
261
|
-
${packageScope}:registry=${withTrailingSlash}
|
|
262
|
-
`;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// src/run.ts
|
|
266
|
-
async function run({
|
|
267
|
-
project,
|
|
268
|
-
overwrite,
|
|
269
|
-
template,
|
|
270
|
-
sdkVersion,
|
|
271
|
-
foundryUrl,
|
|
272
|
-
widgetSetRid,
|
|
273
|
-
osdkPackage,
|
|
274
|
-
osdkRegistryUrl
|
|
275
|
-
}) {
|
|
276
|
-
consola.log("");
|
|
277
|
-
consola.start(`Creating project ${green(project)} using template ${green(template.id)}`);
|
|
278
|
-
const cwd = process.cwd();
|
|
279
|
-
const root = path2.join(cwd, project);
|
|
280
|
-
if (fs2.existsSync(root)) {
|
|
281
|
-
if (overwrite) {
|
|
282
|
-
consola.info(`Overwriting existing project directory`);
|
|
283
|
-
fs2.rmSync(root, {
|
|
284
|
-
recursive: true,
|
|
285
|
-
force: true
|
|
286
|
-
});
|
|
287
|
-
fs2.mkdirSync(root, {
|
|
288
|
-
recursive: true
|
|
289
|
-
});
|
|
290
|
-
} else {
|
|
291
|
-
consola.info(`Reusing existing project directory`);
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
consola.info(`Creating project directory`);
|
|
295
|
-
fs2.mkdirSync(root, {
|
|
296
|
-
recursive: true
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
consola.info(`Copying files into project directory`);
|
|
300
|
-
if (template.files[sdkVersion] == null) {
|
|
301
|
-
throw new Error(`The ${template.label} template does not support a "${sdkVersion}" SDK version.`);
|
|
302
|
-
}
|
|
303
|
-
const files = await template.files[sdkVersion]();
|
|
304
|
-
for (const [filePath, contents] of files) {
|
|
305
|
-
const finalPath = path2.join(root, filePath);
|
|
306
|
-
const dirPath = path2.dirname(finalPath);
|
|
307
|
-
await fs2.promises.mkdir(dirPath, {
|
|
308
|
-
recursive: true
|
|
309
|
-
});
|
|
310
|
-
await fs2.promises.writeFile(finalPath, Buffer.from(contents.body, contents.type === "raw" ? "utf-8" : "base64"));
|
|
311
|
-
}
|
|
312
|
-
const ourPackageJsonPath = findUpSync("package.json", {
|
|
313
|
-
cwd: fileURLToPath(import.meta.url)
|
|
314
|
-
});
|
|
315
|
-
ourPackageJsonPath ? JSON.parse(fs2.readFileSync(ourPackageJsonPath, "utf-8")).version : void 0;
|
|
316
|
-
const clientVersion = "2.1.0-beta.23";
|
|
317
|
-
const templateContext = {
|
|
318
|
-
project,
|
|
319
|
-
foundryUrl,
|
|
320
|
-
widgetSetRid,
|
|
321
|
-
osdkPackage,
|
|
322
|
-
clientVersion: changeVersionPrefix(clientVersion, "^")
|
|
323
|
-
};
|
|
324
|
-
const processFiles = function(dir) {
|
|
325
|
-
fs2.readdirSync(dir).forEach(function(file) {
|
|
326
|
-
file = dir + "/" + file;
|
|
327
|
-
const stat = fs2.statSync(file);
|
|
328
|
-
if (stat.isDirectory()) {
|
|
329
|
-
processFiles(file);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
if (file.endsWith("/_gitignore")) {
|
|
333
|
-
fs2.renameSync(file, file.replace(/\/_gitignore$/, "/.gitignore"));
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
if (!file.endsWith(".hbs")) {
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
const templated = Handlebars.compile(fs2.readFileSync(file, "utf-8"))(templateContext);
|
|
340
|
-
fs2.writeFileSync(file.replace(/.hbs$/, ""), templated);
|
|
341
|
-
fs2.rmSync(file);
|
|
342
|
-
});
|
|
343
|
-
};
|
|
344
|
-
processFiles(root);
|
|
345
|
-
const npmRc = generateNpmRc({
|
|
346
|
-
osdkPackage,
|
|
347
|
-
osdkRegistryUrl
|
|
348
|
-
});
|
|
349
|
-
fs2.writeFileSync(path2.join(root, ".npmrc"), npmRc);
|
|
350
|
-
const foundryConfigJson = generateFoundryConfigJson({
|
|
351
|
-
foundryUrl,
|
|
352
|
-
widgetSetRid,
|
|
353
|
-
directory: template.buildDirectory
|
|
354
|
-
});
|
|
355
|
-
fs2.writeFileSync(path2.join(root, "foundry.config.json"), foundryConfigJson);
|
|
356
|
-
consola.success("Success");
|
|
357
|
-
const cdRelative = path2.relative(cwd, root);
|
|
358
|
-
consola.box({
|
|
359
|
-
message: `Done! Run the following commands to get started:
|
|
360
|
-
|
|
361
|
-
\`cd ${cdRelative}\`
|
|
362
|
-
\`export FOUNDRY_TOKEN=<token>\`
|
|
363
|
-
\`npm install\`
|
|
364
|
-
\`npm run dev\``,
|
|
365
|
-
style: {
|
|
366
|
-
padding: 2,
|
|
367
|
-
borderColor: "green",
|
|
368
|
-
borderStyle: "rounded"
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// src/cli.ts
|
|
374
|
-
async function cli(args = process.argv) {
|
|
375
|
-
const base = yargs(hideBin(args)).version("2.0.0-beta.8").wrap(Math.min(150, yargs().terminalWidth())).strict().help().command("$0 [project] [--<option>]", "Create a new OSDK widget set based on framework templates. Information may be provided through options to skip interactive prompts.", (yargs2) => yargs2.positional("project", {
|
|
376
|
-
type: "string",
|
|
377
|
-
describe: "Project name to create"
|
|
378
|
-
}).option("overwrite", {
|
|
379
|
-
type: "boolean",
|
|
380
|
-
describe: "Overwrite project directory if already exists"
|
|
381
|
-
}).option("beta", {
|
|
382
|
-
type: "boolean",
|
|
383
|
-
describe: "Use templates compatible with the Beta version of the SDK"
|
|
384
|
-
}).option("template", {
|
|
385
|
-
type: "string",
|
|
386
|
-
describe: "Template name to use"
|
|
387
|
-
}).option("sdkVersion", {
|
|
388
|
-
type: "string",
|
|
389
|
-
describe: "The OSDK version to use"
|
|
390
|
-
}).option("foundryUrl", {
|
|
391
|
-
type: "string",
|
|
392
|
-
describe: "URL for the Foundry stack"
|
|
393
|
-
}).option("widgetSetRid", {
|
|
394
|
-
type: "string",
|
|
395
|
-
describe: "Widget set resource identifier (rid)"
|
|
396
|
-
}).option("osdkPackage", {
|
|
397
|
-
type: "string",
|
|
398
|
-
describe: "OSDK package name for application"
|
|
399
|
-
}).option("osdkRegistryUrl", {
|
|
400
|
-
type: "string",
|
|
401
|
-
describe: "URL for NPM registry to install OSDK package"
|
|
402
|
-
}));
|
|
403
|
-
const parsed = base.parseSync();
|
|
404
|
-
const project = await promptProject(parsed);
|
|
405
|
-
const overwrite = await promptOverwrite({
|
|
406
|
-
...parsed,
|
|
407
|
-
project
|
|
408
|
-
});
|
|
409
|
-
const template = await promptTemplate(parsed);
|
|
410
|
-
const sdkVersion = await promptSdkVersion({
|
|
411
|
-
...parsed,
|
|
412
|
-
template
|
|
413
|
-
});
|
|
414
|
-
const foundryUrl = await promptFoundryUrl(parsed);
|
|
415
|
-
const osdkPackage = await promptOsdkPackage(parsed);
|
|
416
|
-
const osdkRegistryUrl = await promptOsdkRegistryUrl(parsed);
|
|
417
|
-
const widgetSetRid = await promptWidgetSetRid(parsed);
|
|
418
|
-
await run({
|
|
419
|
-
project,
|
|
420
|
-
overwrite,
|
|
421
|
-
template,
|
|
422
|
-
sdkVersion,
|
|
423
|
-
foundryUrl,
|
|
424
|
-
widgetSetRid,
|
|
425
|
-
osdkPackage,
|
|
426
|
-
osdkRegistryUrl
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
export { TEMPLATES, cli, run };
|
|
431
|
-
//# sourceMappingURL=index.js.map
|
|
432
|
-
//# sourceMappingURL=index.js.map
|