@osdk/create-app 2.6.0-rc.15 → 2.6.0-rc.16

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -1
  3. package/build/esm/esm-27S7ZNUY.js +492 -0
  4. package/build/esm/esm-27S7ZNUY.js.map +1 -0
  5. package/build/esm/{esm-BFU2C5I6.js → esm-BPDOE2XQ.js} +11 -5
  6. package/build/esm/esm-BPDOE2XQ.js.map +1 -0
  7. package/build/esm/{esm-CE2B34NS.js → esm-BZCH5TWU.js} +10 -4
  8. package/build/esm/esm-BZCH5TWU.js.map +1 -0
  9. package/build/esm/{esm-X2E7QWV3.js → esm-E6VURJO2.js} +308 -97
  10. package/build/esm/esm-E6VURJO2.js.map +1 -0
  11. package/build/esm/{esm-OAZKICK5.js → esm-HPTIRCUT.js} +12 -10
  12. package/build/esm/esm-HPTIRCUT.js.map +1 -0
  13. package/build/esm/{esm-IPIUMRUZ.js → esm-QTVEFJ72.js} +10 -4
  14. package/build/esm/esm-QTVEFJ72.js.map +1 -0
  15. package/build/esm/{esm-UYHS7HJF.js → esm-RL6PMHXG.js} +165 -27
  16. package/build/esm/esm-RL6PMHXG.js.map +1 -0
  17. package/build/esm/{esm-ZNWIB6WR.js → esm-RRX43VDZ.js} +15 -8
  18. package/build/esm/esm-RRX43VDZ.js.map +1 -0
  19. package/build/esm/{esm-N4SPMGQ5.js → esm-VF46BQ3A.js} +12 -10
  20. package/build/esm/esm-VF46BQ3A.js.map +1 -0
  21. package/build/esm/index.js +123 -68
  22. package/build/esm/index.js.map +1 -1
  23. package/build/types/cli.d.ts.map +1 -1
  24. package/build/types/generate/generateEnv.d.ts +2 -2
  25. package/build/types/generate/generateEnv.d.ts.map +1 -1
  26. package/build/types/generate/generateNpmRc.d.ts +2 -1
  27. package/build/types/generate/generateNpmRc.d.ts.map +1 -1
  28. package/build/types/prompts/promptOntologyAndOsdkPackageAndOsdkRegistryUrl.d.ts +12 -0
  29. package/build/types/prompts/promptOntologyAndOsdkPackageAndOsdkRegistryUrl.d.ts.map +1 -0
  30. package/build/types/prompts/promptOntologyAndOsdkPackageAndOsdkRegistryUrl.test.d.ts.map +1 -0
  31. package/build/types/run.d.ts +3 -3
  32. package/build/types/templates.d.ts +3 -1
  33. package/build/types/templates.d.ts.map +1 -1
  34. package/package.json +11 -11
  35. package/build/esm/esm-BFU2C5I6.js.map +0 -1
  36. package/build/esm/esm-CE2B34NS.js.map +0 -1
  37. package/build/esm/esm-IPIUMRUZ.js.map +0 -1
  38. package/build/esm/esm-N4SPMGQ5.js.map +0 -1
  39. package/build/esm/esm-OAZKICK5.js.map +0 -1
  40. package/build/esm/esm-UYHS7HJF.js.map +0 -1
  41. package/build/esm/esm-X2E7QWV3.js.map +0 -1
  42. package/build/esm/esm-YAHWUN5G.js +0 -281
  43. package/build/esm/esm-YAHWUN5G.js.map +0 -1
  44. package/build/esm/esm-ZNWIB6WR.js.map +0 -1
  45. package/build/types/prompts/promptOntologyRid.d.ts +0 -3
  46. package/build/types/prompts/promptOntologyRid.d.ts.map +0 -1
  47. package/build/types/prompts/promptOntologyRid.test.d.ts.map +0 -1
  48. package/build/types/prompts/promptOsdkPackage.d.ts +0 -3
  49. package/build/types/prompts/promptOsdkPackage.d.ts.map +0 -1
  50. package/build/types/prompts/promptOsdkPackage.test.d.ts +0 -1
  51. package/build/types/prompts/promptOsdkPackage.test.d.ts.map +0 -1
  52. package/build/types/prompts/promptOsdkRegistryUrl.d.ts +0 -3
  53. package/build/types/prompts/promptOsdkRegistryUrl.d.ts.map +0 -1
  54. package/build/types/prompts/promptOsdkRegistryUrl.test.d.ts +0 -1
  55. package/build/types/prompts/promptOsdkRegistryUrl.test.d.ts.map +0 -1
  56. /package/build/types/prompts/{promptOntologyRid.test.d.ts → promptOntologyAndOsdkPackageAndOsdkRegistryUrl.test.d.ts} +0 -0
@@ -127,10 +127,32 @@ ${italic("(Example: https://example.palantirfoundry.com)")}`, {
127
127
  return foundryUrl.replace(/\/$/, "");
128
128
  }
129
129
 
130
- // src/prompts/promptOntologyRid.ts
131
- async function promptOntologyRid({
132
- ontology
130
+ // src/prompts/promptOntologyAndOsdkPackageAndOsdkRegistryUrl.ts
131
+ async function promptOntologyAndOsdkPackageAndOsdkRegistryUrl({
132
+ ontology,
133
+ osdkPackage,
134
+ osdkRegistryUrl,
135
+ skipOsdk,
136
+ sdkVersion
133
137
  }) {
138
+ if (skipOsdk) {
139
+ return {};
140
+ }
141
+ if (sdkVersion !== "1.x" && osdkPackage == null && ontology == null && osdkRegistryUrl == null) {
142
+ const skip = await consola.prompt("Will you be using an OSDK in your application?", {
143
+ type: "select",
144
+ options: [{
145
+ label: "Yes, I will be using an OSDK",
146
+ value: "yes"
147
+ }, {
148
+ label: "No, I will only be using Platform APIs",
149
+ value: "no"
150
+ }]
151
+ });
152
+ if (skip === "no") {
153
+ return {};
154
+ }
155
+ }
134
156
  while (ontology == null || !/^ri\.ontology\.[^.]+\.ontology\.[^.]+$/.test(ontology)) {
135
157
  if (ontology != null) {
136
158
  consola.fail("Please enter a valid Ontology resource identifier (rid)");
@@ -140,13 +162,6 @@ ${italic("(Example: ri.ontology.main.ontology.1df1ce4c-f9d2-0f78-a316-287f6ac80b
140
162
  type: "text"
141
163
  });
142
164
  }
143
- return ontology;
144
- }
145
-
146
- // src/prompts/promptOsdkPackage.ts
147
- async function promptOsdkPackage({
148
- osdkPackage
149
- }) {
150
165
  while (osdkPackage == null || !/^@[a-z0-9-]+\/sdk$/.test(osdkPackage)) {
151
166
  if (osdkPackage != null) {
152
167
  consola.fail("Please enter a valid OSDK package name");
@@ -156,13 +171,6 @@ ${italic("(Example: @my-app/sdk)")}`, {
156
171
  type: "text"
157
172
  });
158
173
  }
159
- return osdkPackage;
160
- }
161
-
162
- // src/prompts/promptOsdkRegistryUrl.ts
163
- async function promptOsdkRegistryUrl({
164
- osdkRegistryUrl
165
- }) {
166
174
  while (osdkRegistryUrl == null || !/^https:\/\/[^/]+\/artifacts\/api\/repositories\/ri\.artifacts\.[^/]+\/contents\/release\/npm\/?$/.test(osdkRegistryUrl)) {
167
175
  if (osdkRegistryUrl != null) {
168
176
  consola.fail("Please enter a valid NPM registry URL to install your OSDK package");
@@ -172,7 +180,11 @@ ${italic("(Example: https://example.palantirfoundry.com/artifacts/api/repositori
172
180
  type: "text"
173
181
  });
174
182
  }
175
- return osdkRegistryUrl.replace(/\/$/, "");
183
+ return {
184
+ ontology,
185
+ osdkPackage,
186
+ osdkRegistryUrl: osdkRegistryUrl.replace(/\/$/, "")
187
+ };
176
188
  }
177
189
  async function promptOverwrite({
178
190
  project,
@@ -296,8 +308,8 @@ var TEMPLATES = [
296
308
  buildDirectory: "./dist",
297
309
  hidden: false,
298
310
  files: {
299
- "1.x": getPackageFiles(import('./esm-ZNWIB6WR.js')),
300
- "2.x": getPackageFiles(import('./esm-X2E7QWV3.js'))
311
+ "1.x": getPackageFiles(import('./esm-RRX43VDZ.js')),
312
+ "2.x": getPackageFiles(import('./esm-E6VURJO2.js'))
301
313
  }
302
314
  },
303
315
  // Expo
@@ -308,7 +320,7 @@ var TEMPLATES = [
308
320
  buildDirectory: "./dist",
309
321
  hidden: false,
310
322
  files: {
311
- "2.x": getPackageFiles(import('./esm-UYHS7HJF.js'))
323
+ "2.x": getPackageFiles(import('./esm-RL6PMHXG.js'))
312
324
  }
313
325
  },
314
326
  // Vue
@@ -319,8 +331,8 @@ var TEMPLATES = [
319
331
  buildDirectory: "./dist",
320
332
  hidden: false,
321
333
  files: {
322
- "1.x": getPackageFiles(import('./esm-BFU2C5I6.js')),
323
- "2.x": getPackageFiles(import('./esm-YAHWUN5G.js'))
334
+ "1.x": getPackageFiles(import('./esm-BPDOE2XQ.js')),
335
+ "2.x": getPackageFiles(import('./esm-27S7ZNUY.js'))
324
336
  }
325
337
  },
326
338
  // Tutorial: To do App
@@ -331,8 +343,8 @@ var TEMPLATES = [
331
343
  buildDirectory: "./dist",
332
344
  hidden: true,
333
345
  files: {
334
- "1.x": getPackageFiles(import('./esm-IPIUMRUZ.js')),
335
- "2.x": getPackageFiles(import('./esm-OAZKICK5.js'))
346
+ "1.x": getPackageFiles(import('./esm-QTVEFJ72.js')),
347
+ "2.x": getPackageFiles(import('./esm-HPTIRCUT.js'))
336
348
  }
337
349
  },
338
350
  // Tutorial: To do AIP App
@@ -343,8 +355,8 @@ var TEMPLATES = [
343
355
  buildDirectory: "./dist",
344
356
  hidden: true,
345
357
  files: {
346
- "1.x": getPackageFiles(import('./esm-CE2B34NS.js')),
347
- "2.x": getPackageFiles(import('./esm-N4SPMGQ5.js'))
358
+ "1.x": getPackageFiles(import('./esm-BZCH5TWU.js')),
359
+ "2.x": getPackageFiles(import('./esm-VF46BQ3A.js'))
348
360
  }
349
361
  }
350
362
  ];
@@ -402,6 +414,14 @@ function generateEnvDevelopment({
402
414
  }) {
403
415
  const foundryApiUrl = corsProxy ? "http://localhost:8080" : foundryUrl;
404
416
  const applicationUrl = "http://localhost:8080";
417
+ const ontologyEnvSection = ontology != null ? `
418
+
419
+ # This Ontology RID must match the Ontology RID your Developer Console is associated with.
420
+ # You can check the Ontology on the "Ontology SDK" tab of Developer Console.
421
+ # It typically does not need to be changed.
422
+
423
+ ${envPrefix}FOUNDRY_ONTOLOGY_RID=${ontology}
424
+ ` : "";
405
425
  return `# This env file is intended for developing on your local computer.
406
426
  # To set up development in Foundry's Code Workspaces, see .env.code-workspaces.
407
427
  # To deploy your application to production, see .env.production.
@@ -429,13 +449,7 @@ ${envPrefix}FOUNDRY_API_URL=${foundryApiUrl}
429
449
  # Developer Console. It typically does not need to be changed.
430
450
 
431
451
  ${envPrefix}FOUNDRY_CLIENT_ID=${clientId}
432
-
433
- # This Ontology RID must match the Ontology RID your Developer Console is associated with.
434
- # You can check the Ontology on the "Data Resources" page of Developer Console.
435
- # It typically does not need to be changed.
436
-
437
- ${envPrefix}FOUNDRY_ONTOLOGY_RID=${ontology}
438
- `;
452
+ ${ontologyEnvSection}`;
439
453
  }
440
454
  function generateEnvProduction({
441
455
  envPrefix,
@@ -445,6 +459,14 @@ function generateEnvProduction({
445
459
  ontology
446
460
  }) {
447
461
  const applicationUrlOrDefault = applicationUrl ?? "<Fill in the domain at which you deploy your application>";
462
+ const ontologyEnvSection = ontology != null ? `
463
+
464
+ # This Ontology RID must match the Ontology RID your Developer Console is associated with.
465
+ # You can check the Ontology on the "Ontology SDK" tab of Developer Console.
466
+ # It typically does not need to be changed.
467
+
468
+ ${envPrefix}FOUNDRY_ONTOLOGY_RID=${ontology}
469
+ ` : "";
448
470
  return `# This env file is intended for deploying your application to production.
449
471
  # To set up development on your local computer, see .env.development.
450
472
  # To set up development in Foundry's Code Workspaces, see .env.code-workspaces.
@@ -472,13 +494,7 @@ ${envPrefix}FOUNDRY_API_URL=${foundryUrl}
472
494
  # Developer Console. It typically does not need to be changed.
473
495
 
474
496
  ${envPrefix}FOUNDRY_CLIENT_ID=${clientId}
475
-
476
- # This Ontology RID must match the Ontology RID your Developer Console is associated with.
477
- # You can check the Ontology on the "Data Resources" page of Developer Console.
478
- # It typically does not need to be changed.
479
-
480
- ${envPrefix}FOUNDRY_ONTOLOGY_RID=${ontology}
481
- `;
497
+ ${ontologyEnvSection}`;
482
498
  }
483
499
 
484
500
  // src/generate/generateFoundryConfigJson.ts
@@ -502,14 +518,16 @@ function generateFoundryConfigJson({
502
518
 
503
519
  // src/generate/generateNpmRc.ts
504
520
  function generateNpmRc({
521
+ foundryUrl,
505
522
  osdkPackage,
506
523
  osdkRegistryUrl
507
524
  }) {
508
- const withTrailingSlash = osdkRegistryUrl.endsWith("/") ? osdkRegistryUrl : osdkRegistryUrl + "/";
509
- const withoutProtocol = withTrailingSlash.replace(/^https:\/\//, "");
525
+ const osdkRegistryUrlWithTrailingSlash = osdkRegistryUrl.endsWith("/") ? osdkRegistryUrl : osdkRegistryUrl + "/";
526
+ const formattedFoundryUrl = foundryUrl.replace(/^https:\/\//, "").replace(/\/$/, "");
527
+ const artifactsApiUrl = formattedFoundryUrl + "/artifacts/api/";
510
528
  const packageScope = osdkPackage.split("/")[0];
511
- return `//${withoutProtocol}:_authToken=\${FOUNDRY_TOKEN}
512
- ${packageScope}:registry=${withTrailingSlash}
529
+ return `//${artifactsApiUrl}:_authToken=\${FOUNDRY_TOKEN}
530
+ ${packageScope}:registry=${osdkRegistryUrlWithTrailingSlash}
513
531
  `;
514
532
  }
515
533
 
@@ -569,8 +587,10 @@ async function run({
569
587
  cwd: fileURLToPath(import.meta.url)
570
588
  });
571
589
  ourPackageJsonPath ? JSON.parse(fs2.readFileSync(ourPackageJsonPath, "utf-8")).version : void 0;
572
- const clientVersion = "2.6.0-rc.15";
590
+ const clientVersion = "2.6.0-rc.16";
573
591
  const templateContext = {
592
+ application,
593
+ applicationUrl,
574
594
  project,
575
595
  foundryUrl,
576
596
  osdkPackage,
@@ -580,30 +600,50 @@ async function run({
580
600
  };
581
601
  const processFiles = function(dir) {
582
602
  fs2.readdirSync(dir).forEach(function(file) {
583
- file = dir + "/" + file;
584
- const stat = fs2.statSync(file);
603
+ let fullPath = dir + "/" + file;
604
+ const stat = fs2.statSync(fullPath);
585
605
  if (stat.isDirectory()) {
586
- processFiles(file);
606
+ processFiles(fullPath);
587
607
  return;
588
608
  }
589
- if (file.endsWith("/_gitignore")) {
590
- fs2.renameSync(file, file.replace(/\/_gitignore$/, "/.gitignore"));
609
+ if (fullPath.endsWith("/_gitignore")) {
610
+ fs2.renameSync(fullPath, fullPath.replace(/\/_gitignore$/, "/.gitignore"));
591
611
  return;
592
612
  }
593
- if (!file.endsWith(".hbs")) {
613
+ if (file.includes(".osdk")) {
614
+ if (osdkPackage == null) {
615
+ fs2.rmSync(fullPath);
616
+ return;
617
+ } else {
618
+ fs2.renameSync(fullPath, fullPath.replace(".osdk", ""));
619
+ fullPath = fullPath.replace(".osdk", "");
620
+ }
621
+ } else if (file.includes(".psdk")) {
622
+ if (osdkPackage == null) {
623
+ fs2.renameSync(fullPath, fullPath.replace(".psdk", ""));
624
+ fullPath = fullPath.replace(".psdk", "");
625
+ } else {
626
+ fs2.rmSync(fullPath);
627
+ return;
628
+ }
629
+ }
630
+ if (!fullPath.endsWith(".hbs")) {
594
631
  return;
595
632
  }
596
- const templated = Handlebars.compile(fs2.readFileSync(file, "utf-8"))(templateContext);
597
- fs2.writeFileSync(file.replace(/.hbs$/, ""), templated);
598
- fs2.rmSync(file);
633
+ const templated = Handlebars.compile(fs2.readFileSync(fullPath, "utf-8"))(templateContext);
634
+ fs2.writeFileSync(fullPath.replace(/.hbs$/, ""), templated);
635
+ fs2.rmSync(fullPath);
599
636
  });
600
637
  };
601
638
  processFiles(root);
602
- const npmRc = generateNpmRc({
603
- osdkPackage,
604
- osdkRegistryUrl
605
- });
606
- fs2.writeFileSync(path2.join(root, ".npmrc"), npmRc);
639
+ if (osdkPackage != null && osdkRegistryUrl != null) {
640
+ const npmRc = generateNpmRc({
641
+ osdkPackage,
642
+ osdkRegistryUrl,
643
+ foundryUrl
644
+ });
645
+ fs2.writeFileSync(path2.join(root, ".npmrc"), npmRc);
646
+ }
607
647
  const envDevelopment = generateEnvDevelopment({
608
648
  envPrefix: template.envPrefix,
609
649
  foundryUrl,
@@ -645,7 +685,7 @@ async function run({
645
685
 
646
686
  // src/cli.ts
647
687
  async function cli(args = process.argv) {
648
- const base = yargs(hideBin(args)).version("2.6.0-rc.15").wrap(Math.min(150, yargs().terminalWidth())).strict().help().command("$0 [project] [--<option>]", "Create a new OSDK application based on framework templates. Information may be provided through options to skip interactive prompts.", (yargs2) => yargs2.positional("project", {
688
+ const base = yargs(hideBin(args)).version("2.6.0-rc.16").wrap(Math.min(150, yargs().terminalWidth())).strict().help().command("$0 [project] [--<option>]", "Create a new OSDK application based on framework templates. Information may be provided through options to skip interactive prompts.", (yargs2) => yargs2.positional("project", {
649
689
  type: "string",
650
690
  describe: "Project name to create"
651
691
  }).option("overwrite", {
@@ -675,13 +715,18 @@ async function cli(args = process.argv) {
675
715
  describe: "Application resource identifier (rid)"
676
716
  }).option("ontology", {
677
717
  type: "string",
678
- describe: "Ontology resource identifier (rid)"
718
+ describe: "Ontology resource identifier (rid)",
719
+ conflicts: "skipOsdk"
720
+ }).option("osdkPackage", {
721
+ type: "string",
722
+ describe: "OSDK package name for application",
723
+ conflicts: "skipOsdk"
724
+ }).option("skipOsdk", {
725
+ type: "boolean",
726
+ describe: "Skip filling in OSDK options"
679
727
  }).option("clientId", {
680
728
  type: "string",
681
729
  describe: "OAuth client ID for application"
682
- }).option("osdkPackage", {
683
- type: "string",
684
- describe: "OSDK package name for application"
685
730
  }).option("osdkRegistryUrl", {
686
731
  type: "string",
687
732
  describe: "URL for NPM registry to install OSDK package"
@@ -692,6 +737,11 @@ async function cli(args = process.argv) {
692
737
  type: "string",
693
738
  array: true,
694
739
  describe: "List of client-side scopes to be used when creating a client"
740
+ }).check((argv) => {
741
+ if (argv.skipOsdk && (argv.sdkVersion == null || argv.sdkVersion.startsWith("1."))) {
742
+ throw new Error("The --skipOsdk flag is only allowed when sdkVersion is 2.x. Please set --sdkVersion to 2.x or remove the --skipOsdk flag.");
743
+ }
744
+ return true;
695
745
  }));
696
746
  const parsed = base.parseSync();
697
747
  const project = await promptProject(parsed);
@@ -707,10 +757,15 @@ async function cli(args = process.argv) {
707
757
  const foundryUrl = await promptFoundryUrl(parsed);
708
758
  const applicationUrl = await promptApplicationUrl(parsed);
709
759
  const application = await promptApplicationRid(parsed);
710
- const ontology = await promptOntologyRid(parsed);
711
760
  const clientId = await promptClientId(parsed);
712
- const osdkPackage = await promptOsdkPackage(parsed);
713
- const osdkRegistryUrl = await promptOsdkRegistryUrl(parsed);
761
+ const {
762
+ osdkPackage,
763
+ ontology,
764
+ osdkRegistryUrl
765
+ } = await promptOntologyAndOsdkPackageAndOsdkRegistryUrl({
766
+ ...parsed,
767
+ sdkVersion
768
+ });
714
769
  const corsProxy = await promptCorsProxy(parsed);
715
770
  const scopes = await promptScopes(parsed);
716
771
  await run({