sv-arcgis 1.2.0 → 1.3.0-next.2

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/README.md CHANGED
@@ -3,8 +3,7 @@
3
3
  - SvelteKit installed (`npx sv create [project_name]`)
4
4
 
5
5
  ## 🗜️ Setup
6
-
7
- 1. Install sv-arcgis `npm i sv-arcgis`
6
+ 1. Install [sv-arcgis](https://www.npmjs.com/package/sv-arcgis) `npm i sv-arcgis`
8
7
  2. Run sv-arcgis `npx sv-arcgis`
9
8
  3. ⚠️ Follow instructions in terminal
10
9
 
@@ -1,37 +1,37 @@
1
1
  #!/usr/bin/env node
2
- const fs = require('fs');
3
- const path = require('path');
4
- const { execSync } = require('child_process');
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+ const { execSync } = require("child_process");
5
5
 
6
- const packageJsonPath = path.join(process.cwd(), 'package.json');
6
+ const packageJsonPath = path.join(process.cwd(), "package.json");
7
7
 
8
8
  if (!fs.existsSync(packageJsonPath)) {
9
- console.error('No package.json found in current directory');
9
+ console.error("No package.json found in current directory");
10
10
  process.exit(1);
11
11
  }
12
12
 
13
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
13
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
14
14
 
15
15
  // Detect package manager
16
- const hasPnpmLock = fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'));
17
- const hasYarnLock = fs.existsSync(path.join(process.cwd(), 'yarn.lock'));
16
+ const hasPnpmLock = fs.existsSync(path.join(process.cwd(), "pnpm-lock.yaml"));
17
+ const hasYarnLock = fs.existsSync(path.join(process.cwd(), "yarn.lock"));
18
18
 
19
- let packageManager = 'npm';
19
+ let packageManager = "npm";
20
20
  if (hasPnpmLock) {
21
- packageManager = 'pnpm';
21
+ packageManager = "pnpm";
22
22
  } else if (hasYarnLock) {
23
- packageManager = 'yarn';
23
+ packageManager = "yarn";
24
24
  }
25
25
 
26
26
  // Create config directory
27
- const configDirectory = path.join(process.cwd(), '.config');
27
+ const configDirectory = path.join(process.cwd(), ".config");
28
28
  if (!fs.existsSync(configDirectory)) {
29
29
  fs.mkdirSync(configDirectory, { recursive: true });
30
30
  // console.log("✅ Created .config directory");
31
31
  }
32
32
 
33
33
  // Create init-sv-arcgis.js file
34
- const initConfigPath = path.join(configDirectory, 'init-sv-arcgis.js');
34
+ const initConfigPath = path.join(configDirectory, "init-sv-arcgis.js");
35
35
  const initConfigContent = `#!/usr/bin/env node
36
36
 
37
37
  import fs from 'fs';
@@ -71,10 +71,11 @@ const onCancel = () => {
71
71
 
72
72
  async function generateConfig() {
73
73
 
74
- // Check if SvelteKit is installed
74
+ // Check if Svelte/SvelteKit is installed
75
+ const isSvelte = fs.existsSync(path.join(process.cwd(), 'src/App.svelte'));
75
76
  const isSvelteKit = fs.existsSync(path.join(process.cwd(), 'src/routes/+page.svelte'));
76
- if (!isSvelteKit) {
77
- console.log("🛑 This doesn\'t seem like a SvelteKit project.");
77
+ if (!isSvelte && !isSvelteKit) {
78
+ console.log("🛑 This doesn\'t seem like a Svelte/SvelteKit project.");
78
79
  console.log("🛑 Have you ran 'npx sv create ./' yet?");
79
80
  process.exit(1);
80
81
  }
@@ -216,7 +217,7 @@ const arcGisApiKey = await prompts([
216
217
  {
217
218
  type: 'text',
218
219
  name: 'ARC_GIS_API_KEY',
219
- message: 'Enter your ArcGIS API key (optional)',
220
+ message: 'Enter your ArcGIS API key',
220
221
  validate: value => {
221
222
  global.arcGisApiKeyIsNull = value.length === 0;
222
223
  return true;
@@ -229,7 +230,7 @@ const arcGisClientId = await prompts([
229
230
  {
230
231
  type: 'text',
231
232
  name: 'ARC_GIS_CLIENT_ID',
232
- message: 'Enter your ArcGIS Client ID (optional)',
233
+ message: 'Enter your ArcGIS Client ID',
233
234
  validate: value => {
234
235
  global.arcGisClientIdIsNull = value.length === 0;
235
236
  return true;
@@ -242,7 +243,7 @@ const arcGisClientSecret = await prompts([
242
243
  {
243
244
  type: 'text',
244
245
  name: 'ARC_GIS_CLIENT_SECRET',
245
- message: 'Enter your ArcGIS Client Secret (optional)',
246
+ message: 'Enter your ArcGIS Client Secret',
246
247
  validate: value => {
247
248
  global.arcGisClientSecretIsNull = value.length === 0;
248
249
  return true;
@@ -332,7 +333,7 @@ if (calcite.CALCITE === true) {
332
333
  console.log("📦 Installing ArcGIS Core, Map Components, and Calcite Components...");
333
334
  initPromises.push(
334
335
  new Promise((resolve, reject) => {
335
- exec(\`\${packageManager} install @arcgis/core@4.31.6 @arcgis/map-components@4.31.6 @esri/calcite-components@2.13.0\`, (error, stdout, stderr) => {
336
+ exec(\`\${packageManager} install @arcgis/core@4.33.12 @arcgis/map-components@4.33.12 @esri/calcite-components@2.13.0\`, (error, stdout, stderr) => {
336
337
  if (error) {
337
338
  console.log('error:', chalk.white.bgRed(error.message));
338
339
  reject(error);
@@ -346,7 +347,7 @@ if (calcite.CALCITE === true) {
346
347
  console.log("📦 Installing ArcGIS Core and Map Components...");
347
348
  initPromises.push(
348
349
  new Promise((resolve, reject) => {
349
- exec(\`\${packageManager} install @arcgis/core@4.31.6 @arcgis/map-components@4.31.6\`, (error, stdout, stderr) => {
350
+ exec(\`\${packageManager} install @arcgis/core@4.33.12 @arcgis/map-components@4.33.12\`, (error, stdout, stderr) => {
350
351
  if (error) {
351
352
  console.log('error:', chalk.white.bgRed(error.message));
352
353
  reject(error);
@@ -367,207 +368,401 @@ if (initPromises.length > 0) {
367
368
  } catch (error) {
368
369
  console.log("");
369
370
  console.log("❌ Package installation failed:", error.message);
371
+ console.log("");
372
+ console.log("❓ Do you already have one of these installed @arcgis/core, @arcgis/map-components, or @esri/calcite-components? This may be the issue. If you're comfortable with it, uninstall them, delete the node_modules folder, package-lock.json, and run this tool again.");
370
373
  }
371
374
  }
372
375
 
373
376
  // Add demo page?
374
377
  if (demo.DEMO === true) {
375
- // Create directory called 'arcgis' in './src/routes/'
376
- const arcgisRouteDir = path.join(process.cwd(), 'src', 'routes', 'arcgis');
378
+ let arcgisRouteDir;
379
+ if (isSvelte) {
380
+ // console.log("📦 Svelte DEMO...");
381
+ // Create directory called 'arcgis' in './src/'
382
+
383
+ arcgisRouteDir = path.join(process.cwd(), 'src', 'lib');
384
+ } else if (isSvelteKit) {
385
+ console.log("📦 SvelteKit DEMO...");
386
+ // Create directory called 'arcgis' in './src/routes/'
387
+
388
+ arcgisRouteDir = path.join(process.cwd(), 'src', 'routes', 'arcgis');
389
+ }
390
+
377
391
  if (!fs.existsSync(arcgisRouteDir)) {
378
392
  fs.mkdirSync(arcgisRouteDir, { recursive: true });
379
393
  }
380
394
 
381
- // Create a demo page within this directory called '+page.svelte'
382
- const demoPagePath = path.join(arcgisRouteDir, '+page.svelte');
395
+ // Create a demo page within this directory
396
+ const demoPagePath = isSvelte ? path.join(arcgisRouteDir, 'ArcGIS.svelte') : path.join(arcgisRouteDir, '+page.svelte');
397
+ let demoPageContent;
383
398
 
384
- const demoPageContent = \`<script lang="ts">
385
- // config
386
- import config from "$lib/config";
387
-
388
- // sk
389
- import { onMount } from "svelte";
390
- import { browser } from "$app/environment";
391
- import { env } from "$env/dynamic/public";
392
-
393
- // variables
394
- let mapWrap: HTMLDivElement | null = $state(null);
395
-
396
- onMount(() => {
397
- console.log("env", env);
398
- console.log("config", config);
399
- console.log("mapWrap", mapWrap);
400
- });
399
+ if (isSvelteKit) {
400
+ demoPageContent = \`<script lang="ts">
401
+ // config
402
+ import config from "$lib/config";
403
+
404
+ // sk
405
+ import { onMount } from "svelte";
406
+ import { browser } from "$app/environment";
407
+ import { env } from "$env/dynamic/public";
408
+
409
+ // variables
410
+ let mapWrap: HTMLDivElement | null = $state(null);
411
+
412
+ onMount(() => {
413
+ console.log("env", env);
414
+ console.log("config", config);
415
+ console.log("mapWrap", mapWrap);
416
+ });
401
417
 
402
- if (browser) {
403
- import("@arcgis/map-components/dist/loader").then(
404
- ({ defineCustomElements }) => {
405
- defineCustomElements(window, {
406
- resourcesUrl: "https://js.arcgis.com/map-components/4.31.6/assets",
407
- });
408
- }
409
- );
410
- }
411
- </script>
412
-
413
- <svelte:head>
414
- <title>🗺️ SV + ArcGIS Demo</title>
415
- </svelte:head>
416
-
417
- <main class="e-demo">
418
- {#if config.SECURITY_CLASSIFICATION}
419
- <div
420
- class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
421
- >
422
- Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
423
- </div>
424
- {/if}
425
- <div class="e-demo-container">
426
- <div class="e-demo-header">
427
- <h1>🗺️ SV + ArcGIS Demo</h1>
428
- </div>
429
- <div class="e-demo-map-wrap" bind:this={mapWrap}>
430
- <arcgis-map item-id="05e015c5f0314db9a487a9b46cb37eca">
431
- <arcgis-zoom position="top-left"></arcgis-zoom>
432
- </arcgis-map>
433
- {#if config.CALCITE}
434
- <calcite-button href="/" appearance="solid" scale="m">
435
- Go Home
436
- </calcite-button>
437
- {/if}
438
- </div>
439
- </div>
440
- {#if config.SECURITY_CLASSIFICATION}
441
- <div
442
- class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
443
- >
444
- Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
418
+ if (browser) {
419
+ import("@arcgis/map-components/dist/loader").then(
420
+ ({ defineCustomElements }) => {
421
+ defineCustomElements(window, {
422
+ resourcesUrl: "https://js.arcgis.com/map-components/4.33.12/assets",
423
+ });
424
+ }
425
+ );
426
+ }
427
+ </script>
428
+
429
+ <svelte:head>
430
+ <title>🗺️ SV + ArcGIS Demo</title>
431
+ </svelte:head>
432
+
433
+ <main class="e-demo">
434
+ {#if config.SECURITY_CLASSIFICATION}
435
+ <div
436
+ class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
437
+ >
438
+ Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
439
+ </div>
440
+ {/if}
441
+ <div class="e-demo-container">
442
+ <div class="e-demo-header">
443
+ <h1>🗺️ SV + ArcGIS Demo</h1>
444
+ </div>
445
+ <div class="e-demo-map-wrap" bind:this={mapWrap}>
446
+ <arcgis-map item-id="05e015c5f0314db9a487a9b46cb37eca">
447
+ <arcgis-zoom position="top-left"></arcgis-zoom>
448
+ </arcgis-map>
449
+ {#if config.CALCITE}
450
+ <calcite-button href="/" appearance="solid" scale="m">
451
+ Go Home
452
+ </calcite-button>
453
+ {/if}
454
+ </div>
445
455
  </div>
446
- {/if}
447
- </main>
448
-
449
- <style>
450
- @import "https://js.arcgis.com/4.31/@arcgis/core/assets/esri/themes/dark/main.css";\${calcite.CALCITE ? '\\n @import "@esri/calcite-components/dist/calcite/calcite.css";' : ''}
451
-
452
- :global(body:has(.e-demo)) {
453
- margin: 0;
454
- padding: 0;
455
- height: 100%;
456
- width: 100%;
457
- background: #212121;
458
- }
459
-
460
- .e-demo {
461
- display: grid;
462
- grid-template-rows: 24px 1fr 24px;
463
- height: 100vh;
464
- }
465
-
466
- .e-demo-container {
467
- display: flex;
468
- flex-direction: column;
469
- align-items: center;
470
- }
471
-
472
- .e-demo-header {
473
- padding: 1rem;
474
- color: #f1f1f1;
456
+ {#if config.SECURITY_CLASSIFICATION}
457
+ <div
458
+ class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
459
+ >
460
+ Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
461
+ </div>
462
+ {/if}
463
+ </main>
464
+
465
+ <style>
466
+ @import "https://js.arcgis.com/4.31/@arcgis/core/assets/esri/themes/dark/main.css";\${calcite.CALCITE ? '\\n @import "@esri/calcite-components/dist/calcite/calcite.css";' : ''}
467
+
468
+ :global(body:has(.e-demo)) {
469
+ margin: 0;
470
+ padding: 0;
471
+ height: 100%;
472
+ width: 100%;
473
+ background: #212121;
474
+ }
475
475
 
476
- translate: 0 0;
477
- transition: translate 1s ease-out;
476
+ .e-demo {
477
+ display: grid;
478
+ grid-template-rows: 24px 1fr 24px;
479
+ height: 100vh;
480
+ }
478
481
 
479
- @starting-style {
480
- translate: 0 -4px;
482
+ .e-demo-container {
483
+ display: flex;
484
+ flex-direction: column;
485
+ align-items: center;
481
486
  }
482
- }
483
487
 
484
- .e-demo-map-wrap {
485
- display: flex;
486
- flex-direction: column;
487
- gap: 2rem;
488
- width: 50vmax;
489
- height: 100vh;
490
- margin-inline: auto;
491
- margin: 0;
492
- padding: 0;
493
- padding-block-end: 2rem;
494
-
495
- & arcgis-map {
496
- width: 100%;
497
- height: 50vh;
488
+ .e-demo-header {
489
+ padding: 1rem;
490
+ color: #f1f1f1;
498
491
 
499
- opacity: 1;
500
- transition: opacity 2s ease-out;
492
+ translate: 0 0;
493
+ transition: translate 1s ease-out;
501
494
 
502
495
  @starting-style {
503
- opacity: 0;
496
+ translate: 0 -4px;
504
497
  }
505
498
  }
506
499
 
507
- & calcite-button {
508
- align-self: center;
509
- }
510
- }
500
+ .e-demo-map-wrap {
501
+ display: flex;
502
+ flex-direction: column;
503
+ gap: 2rem;
504
+ width: 50vmax;
505
+ height: 100vh;
506
+ margin-inline: auto;
507
+ margin: 0;
508
+ padding: 0;
509
+ padding-block-end: 2rem;
510
+
511
+ & arcgis-map {
512
+ width: 100%;
513
+ height: 50vh;
514
+
515
+ opacity: 1;
516
+ transition: opacity 2s ease-out;
517
+
518
+ @starting-style {
519
+ opacity: 0;
520
+ }
521
+ }
511
522
 
512
- .e-demo-security-bar {
513
- position: sticky;
514
- display: flex;
515
- align-items: center;
516
- justify-content: center;
517
- inset-block-start: 0;
518
- height: 22px;
519
- background-color: #000;
520
- color: #fff;
521
- margin: 0;
522
- font-size: 14px;
523
- z-index: 1;
524
-
525
- &:not(:first-of-type) {
526
- inset-block-end: 0;
523
+ & calcite-button {
524
+ align-self: center;
525
+ }
527
526
  }
528
527
 
529
- &.e-demo-security-bar--classified {
528
+ .e-demo-security-bar {
529
+ position: sticky;
530
+ display: flex;
531
+ align-items: center;
532
+ justify-content: center;
533
+ inset-block-start: 0;
534
+ height: 22px;
535
+ background-color: #000;
530
536
  color: #fff;
531
- background-color: #723d9a;
537
+ margin: 0;
538
+ font-size: 14px;
539
+ z-index: 1;
540
+
541
+ &:not(:first-of-type) {
542
+ inset-block-end: 0;
543
+ }
544
+
545
+ &.e-demo-security-bar--classified {
546
+ color: #fff;
547
+ background-color: #723d9a;
548
+ }
549
+ &.e-demo-security-bar--confidential {
550
+ color: #fff;
551
+ background-color: #0033a0;
552
+ }
553
+ &.e-demo-security-bar--controlled_unclassified_information {
554
+ color: #fff;
555
+ background-color: #3d1e5a;
556
+ }
557
+ &.e-demo-security-bar--secret {
558
+ color: #fff;
559
+ background-color: #c8102e;
560
+ }
561
+ &.e-demo-security-bar--top_secret {
562
+ color: #000;
563
+ background-color: #ff671f;
564
+ }
565
+ &.e-demo-security-bar--top_secret_sensitive_compartment_information {
566
+ color: #000;
567
+ background-color: #f7ea48;
568
+ }
569
+ &.e-demo-security-bar--unclassified {
570
+ color: #fff;
571
+ background-color: #007a33;
572
+ }
532
573
  }
533
- &.e-demo-security-bar--confidential {
534
- color: #fff;
535
- background-color: #0033a0;
574
+ </style>
575
+ \`;
576
+ }
577
+
578
+ if (isSvelte) {
579
+ demoPageContent = \`<script>
580
+ // config
581
+ import config from "./config";
582
+
583
+ // sk
584
+ import { onMount } from "svelte";
585
+
586
+ // variables
587
+ let mapWrap = $state(null);
588
+
589
+ onMount(() => {
590
+ console.log("config", config);
591
+ console.log("mapWrap", mapWrap);
592
+ });
593
+
594
+ import("@arcgis/map-components/dist/loader").then(
595
+ ({ defineCustomElements }) => {
596
+ defineCustomElements(window, {
597
+ resourcesUrl: "https://js.arcgis.com/map-components/4.33.12/assets",
598
+ });
599
+ }
600
+ );
601
+ </script>
602
+
603
+ <svelte:head>
604
+ <title>🗺️ SV + ArcGIS Demo</title>
605
+ </svelte:head>
606
+
607
+ <main class="e-demo">
608
+ {#if config.SECURITY_CLASSIFICATION}
609
+ <div
610
+ class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
611
+ >
612
+ Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
613
+ </div>
614
+ {/if}
615
+ <div class="e-demo-container">
616
+ <div class="e-demo-header">
617
+ <h1>🗺️ SV + ArcGIS Demo</h1>
618
+ </div>
619
+ <div class="e-demo-map-wrap" bind:this={mapWrap}>
620
+ <arcgis-map item-id="05e015c5f0314db9a487a9b46cb37eca">
621
+ <arcgis-zoom position="top-left"></arcgis-zoom>
622
+ </arcgis-map>
623
+ {#if config.CALCITE}
624
+ <calcite-button href="/" appearance="solid" scale="m">
625
+ Go Home
626
+ </calcite-button>
627
+ {/if}
628
+ </div>
629
+ </div>
630
+ {#if config.SECURITY_CLASSIFICATION}
631
+ <div
632
+ class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
633
+ >
634
+ Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
635
+ </div>
636
+ {/if}
637
+ </main>
638
+
639
+ <style>
640
+ @import "https://js.arcgis.com/4.31/@arcgis/core/assets/esri/themes/dark/main.css";\${calcite.CALCITE ? '\\n @import "@esri/calcite-components/dist/calcite/calcite.css";' : ''}
641
+
642
+ :global(body:has(.e-demo)) {
643
+ margin: 0;
644
+ padding: 0;
645
+ height: 100%;
646
+ width: 100%;
647
+ background: #212121;
536
648
  }
537
- &.e-demo-security-bar--controlled_unclassified_information {
538
- color: #fff;
539
- background-color: #3d1e5a;
649
+
650
+ .e-demo {
651
+ display: grid;
652
+ grid-template-rows: 24px 1fr 24px;
653
+ height: 100vh;
540
654
  }
541
- &.e-demo-security-bar--secret {
542
- color: #fff;
543
- background-color: #c8102e;
655
+
656
+ .e-demo-container {
657
+ display: flex;
658
+ flex-direction: column;
659
+ align-items: center;
544
660
  }
545
- &.e-demo-security-bar--top_secret {
546
- color: #000;
547
- background-color: #ff671f;
661
+
662
+ .e-demo-header {
663
+ padding: 1rem;
664
+ color: #f1f1f1;
665
+
666
+ translate: 0 0;
667
+ transition: translate 1s ease-out;
668
+
669
+ @starting-style {
670
+ translate: 0 -4px;
671
+ }
548
672
  }
549
- &.e-demo-security-bar--top_secret_sensitive_compartment_information {
550
- color: #000;
551
- background-color: #f7ea48;
673
+
674
+ .e-demo-map-wrap {
675
+ display: flex;
676
+ flex-direction: column;
677
+ gap: 2rem;
678
+ width: 50vmax;
679
+ height: 100vh;
680
+ margin-inline: auto;
681
+ margin: 0;
682
+ padding: 0;
683
+ padding-block-end: 2rem;
684
+
685
+ & arcgis-map {
686
+ width: 100%;
687
+ height: 50vh;
688
+
689
+ opacity: 1;
690
+ transition: opacity 2s ease-out;
691
+
692
+ @starting-style {
693
+ opacity: 0;
694
+ }
695
+ }
696
+
697
+ & calcite-button {
698
+ align-self: center;
699
+ }
552
700
  }
553
- &.e-demo-security-bar--unclassified {
701
+
702
+ .e-demo-security-bar {
703
+ position: sticky;
704
+ display: flex;
705
+ align-items: center;
706
+ justify-content: center;
707
+ inset-block-start: 0;
708
+ height: 22px;
709
+ background-color: #000;
554
710
  color: #fff;
555
- background-color: #007a33;
711
+ margin: 0;
712
+ font-size: 14px;
713
+ z-index: 1;
714
+
715
+ &:not(:first-of-type) {
716
+ inset-block-end: 0;
717
+ }
718
+
719
+ &.e-demo-security-bar--classified {
720
+ color: #fff;
721
+ background-color: #723d9a;
722
+ }
723
+ &.e-demo-security-bar--confidential {
724
+ color: #fff;
725
+ background-color: #0033a0;
726
+ }
727
+ &.e-demo-security-bar--controlled_unclassified_information {
728
+ color: #fff;
729
+ background-color: #3d1e5a;
730
+ }
731
+ &.e-demo-security-bar--secret {
732
+ color: #fff;
733
+ background-color: #c8102e;
734
+ }
735
+ &.e-demo-security-bar--top_secret {
736
+ color: #000;
737
+ background-color: #ff671f;
738
+ }
739
+ &.e-demo-security-bar--top_secret_sensitive_compartment_information {
740
+ color: #000;
741
+ background-color: #f7ea48;
742
+ }
743
+ &.e-demo-security-bar--unclassified {
744
+ color: #fff;
745
+ background-color: #007a33;
746
+ }
556
747
  }
557
- }
558
- </style>
559
- \`;
748
+ </style>
749
+ \`;
750
+ }
560
751
 
561
752
  fs.writeFileSync(demoPagePath, demoPageContent);
562
- console.log(\`✅ Created demo page at ./src/routes/arcgis/+page.svelte\`);
563
-
564
- // Update root page with link to demo
565
- const rootRouteDir = path.join(process.cwd(), 'src', 'routes');
566
- const rootPagePath = path.join(rootRouteDir, '+page.svelte');
567
- const rootPageUpdate = \`<p>Visit the <a href="arcgis">arcgis demo page</a> and view console.log output</p>\`;
568
-
753
+ if (isSvelte) {
754
+ console.log(\`✅ Created demo page at ./src/lib/arcgis/ArcGIS.svelte\`);
755
+ } else {
756
+ console.log(\`✅ Created demo page at ./src/routes/arcgis/+page.svelte\`);
757
+ }
758
+
759
+ // Update root page
760
+ const rootRouteDir = isSvelte ? path.join(process.cwd(), 'src') : path.join(process.cwd(), 'src', 'routes');
761
+ const rootPagePath = isSvelte ? path.join(rootRouteDir, 'App.svelte') : path.join(rootRouteDir, '+page.svelte');
762
+ const rootPageUpdate = isSvelte ? \`import ArcGIS from './lib/ArcGIS.svelte';\` : \`<p>Visit the <a href="arcgis">arcgis demo page</a> and view console.log output</p>\`;
763
+
569
764
  // Read existing root page content and append the demo link
570
- if (fs.existsSync(rootPagePath)) {
765
+ if (fs.existsSync(rootPagePath) && isSvelteKit) {
571
766
  const existingContent = fs.readFileSync(rootPagePath, 'utf8');
572
767
  if (!existingContent.includes('arcgis demo page')) {
573
768
  const updatedContent = existingContent + \`\n\` + rootPageUpdate;
@@ -575,6 +770,22 @@ if (demo.DEMO === true) {
575
770
  }
576
771
  console.log(\`✅ Updated homepage with demo link\`);
577
772
  }
773
+
774
+ if (fs.existsSync(rootPagePath) && isSvelte) {
775
+ const existingContent = fs.readFileSync(rootPagePath, 'utf8');
776
+ if (!existingContent.includes('ArcGIS.svelte')) {
777
+ const scriptTagRegex = /(<script[^>]*>)/;
778
+ const match = existingContent.match(scriptTagRegex);
779
+ if (match) {
780
+ const insertionPoint = match.index + match[0].length;
781
+ const updatedContent =
782
+ existingContent.slice(0, insertionPoint) + rootPageUpdate + existingContent.slice(insertionPoint);
783
+ fs.writeFileSync(rootPagePath, updatedContent);
784
+ }
785
+
786
+ console.log('nice');
787
+ }
788
+ }
578
789
  }
579
790
 
580
791
  const config = {
@@ -669,7 +880,8 @@ console.log("✅ Created .config/init-sv-arcgis.js");
669
880
 
670
881
  // Add script
671
882
  if (!packageJson.scripts) packageJson.scripts = {};
672
- packageJson.scripts.config = 'SUPPRESS_NO_CONFIG_WARNING=true node ./.config/init-sv-arcgis.js';
883
+ packageJson.scripts.config =
884
+ "SUPPRESS_NO_CONFIG_WARNING=true node ./.config/init-sv-arcgis.js";
673
885
 
674
886
  // Write back to package.json
675
887
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
@@ -678,12 +890,19 @@ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
678
890
  console.log("📦 Installing required dependencies...");
679
891
 
680
892
  try {
681
- if (packageManager === 'pnpm') {
682
- execSync('pnpm add -D chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0', { stdio: 'inherit' });
683
- } else if (packageManager === 'yarn') {
684
- execSync('yarn add -D chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0', { stdio: 'inherit' });
893
+ if (packageManager === "pnpm") {
894
+ execSync("pnpm add -D chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0", {
895
+ stdio: "inherit",
896
+ });
897
+ } else if (packageManager === "yarn") {
898
+ execSync("yarn add -D chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0", {
899
+ stdio: "inherit",
900
+ });
685
901
  } else {
686
- execSync('npm install --save-dev chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0', { stdio: 'inherit' });
902
+ execSync(
903
+ "npm install --save-dev chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0",
904
+ { stdio: "inherit" }
905
+ );
687
906
  }
688
907
  console.log("✅ Dependencies installed successfully");
689
908
  } catch (error) {
@@ -695,9 +914,9 @@ console.log("✅ Added config script to package.json");
695
914
  console.log("");
696
915
 
697
916
  console.log("🚀 Now run:");
698
- if (packageManager === 'pnpm') {
917
+ if (packageManager === "pnpm") {
699
918
  console.log(" `pnpm run config`");
700
- } else if (packageManager === 'yarn') {
919
+ } else if (packageManager === "yarn") {
701
920
  console.log(" `yarn run config`");
702
921
  } else {
703
922
  console.log(" `npm run config`");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv-arcgis",
3
- "version": "1.2.0",
3
+ "version": "1.3.0-next.2",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "sv-arcgis": "./bin/sv-arcgis-setup.js"