sv-arcgis 1.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 ADDED
File without changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Joe Allen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ ## πŸ—œοΈ Setup
2
+
3
+ 1. Install SvelteKit `npx sv create [project_name]`.
4
+ 2. Install sv-arcgis `npx sv-arcgis`.
5
+ 3. ⚠️ Follow instructions in terminal. ⚠️️
6
+
7
+ ## πŸ“• Notes
8
+
9
+ - Using this will install @arcgis/core@4.31.6. (Testing has not been done on later releases)
10
+ - If you choose 'Yes' to Map components, @arcgis/map-components@4.31.6 will be installed. (Testing has not been done on later releases).
11
+ - If you choose 'Yes' to Calcite, @esri/calcite-components@2.13.0 will be installed. (Testing has not been done on later releases).
12
+
13
+ ## πŸ—ΊοΈ Roadmap
14
+
15
+ - Option for / intergrate OAuth2 https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/arcgis-apis/
16
+ - Create tests (see https://www.youtube.com/watch?v=Xk8yaN9_PZA)
17
+ - Create CI / CD (w/ tests)
18
+
19
+ ## πŸ™ Help
20
+
21
+ - ArcGIS / Calcite Issues?: Check new releases https://developers.arcgis.com/calcite-design-system/releases (see Compatibility section for each release)
22
+ - PRs, Issues, etc. are always welcome.
@@ -0,0 +1,738 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
6
+
7
+ if (!fs.existsSync(packageJsonPath)) {
8
+ console.error('No package.json found in current directory');
9
+ process.exit(1);
10
+ }
11
+
12
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
13
+
14
+ // Detect package manager
15
+ const hasPnpmLock = fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'));
16
+ const hasYarnLock = fs.existsSync(path.join(process.cwd(), 'yarn.lock'));
17
+
18
+ let packageManager = 'npm';
19
+ if (hasPnpmLock) {
20
+ packageManager = 'pnpm';
21
+ } else if (hasYarnLock) {
22
+ packageManager = 'yarn';
23
+ }
24
+
25
+ // Create config directory
26
+ const configDirectory = path.join(process.cwd(), '.config');
27
+ if (!fs.existsSync(configDirectory)) {
28
+ fs.mkdirSync(configDirectory, { recursive: true });
29
+ // console.log("βœ… Created .config directory");
30
+ }
31
+
32
+ // Create init-sv-arcgis.js file
33
+ const initConfigPath = path.join(configDirectory, 'init-sv-arcgis.js');
34
+ const initConfigContent = `#!/usr/bin/env node
35
+
36
+ import fs from 'fs';
37
+ import path from 'path';
38
+ import prompts from 'prompts';
39
+ import chalk from 'chalk';
40
+
41
+ import { exec } from 'node:child_process';
42
+
43
+ const packageJsonContent = fs.readFileSync(path.join(process.cwd(), './package.json'), 'utf8');
44
+ const usesTypeScript = fs.existsSync(path.join(process.cwd(), 'tsconfig.json'));
45
+ const packageInfo = JSON.parse(packageJsonContent);
46
+ const version = packageInfo.version;
47
+ let configPath;
48
+ let envPath;
49
+ let envExamplePath;
50
+
51
+
52
+ // Write to ./src/lib/config/index.js
53
+ // Prompts user for:
54
+ // PORTAL_URL
55
+ // WEBMAP_ID
56
+ // APP_ID
57
+ // BASE
58
+ // APP_NAME
59
+ // SECURITY_CLASSIFICATION
60
+ // MAP_COMPONENTS
61
+ // CALCITE
62
+ // API_KEY
63
+ // CLIENT_ID
64
+ // CLIENT_SECRET
65
+
66
+ // Respect terminating the process (ctrl+c)
67
+ const onCancel = () => {
68
+ console.log("πŸ›‘ Setup canceled. Exiting...");
69
+ process.exit(0);
70
+ };
71
+
72
+ async function generateConfig() {
73
+
74
+ // Check if SvelteKit is installed
75
+ 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.");
78
+ console.log("πŸ›‘ Have you ran 'npx sv create ./' yet?");
79
+ process.exit(1);
80
+ }
81
+
82
+ // const environment = await prompts([
83
+ // {
84
+ // type: 'select',
85
+ // name: 'ENVIRONMENT',
86
+ // message: 'What environment do you want to setup?',
87
+ // choices: [
88
+ // { title: 'development', value: 'development' },
89
+ // { title: 'staging', value: 'staging' },
90
+ // { title: 'production', value: 'production' },
91
+ // ],
92
+ // validate: value => {
93
+ // global.environment = value;
94
+ // return true;
95
+ // }
96
+ // }
97
+ // ], { onCancel });
98
+ // console.log("");
99
+
100
+ // Set env
101
+ // global.env = environment.ENVIRONMENT;
102
+
103
+ // Check if env specific config file already exists
104
+ configPath = path.join(process.cwd(), usesTypeScript ? './src/lib/config/index.ts' : './src/lib/config/index.js');
105
+ envPath = path.join(process.cwd(), \`.env\`);
106
+ envExamplePath = path.join(process.cwd(), \`.env.example\`);
107
+
108
+ // Warn if exists
109
+ if (fs.existsSync(configPath) || fs.existsSync(envPath)) {
110
+
111
+ console.log("⚠️ Warning");
112
+ console.log("");
113
+
114
+ const { overwrite } = await prompts({
115
+ type: 'confirm',
116
+ name: 'overwrite',
117
+ message: 'Config and / or .env file already exist. Overwrite?',
118
+ initial: false
119
+ });
120
+
121
+ // Show cancelled msg
122
+ if (!overwrite) {
123
+ console.log("Setup canceled. Existing configuration preserved.");
124
+ return;
125
+ }
126
+ }
127
+
128
+ // Start config!
129
+ console.log("");
130
+ console.log("πŸ‘‹ Hello");
131
+ console.log("");
132
+
133
+ // Use package.json version, else...
134
+ const VERSION = { version } ? version : '0.1.0';
135
+
136
+ const appName = await prompts([
137
+ {
138
+ type: 'text',
139
+ name: 'APP_NAME',
140
+ message: 'Enter your appName',
141
+ validate: value => {
142
+ global.appNameIsNull = value.length === 0;
143
+ return true;
144
+ }
145
+ }
146
+ ], { onCancel });
147
+ console.log("");
148
+
149
+ const base = await prompts([
150
+ {
151
+ type: 'text',
152
+ name: 'BASE',
153
+ message: 'Enter your baseUrl (e.g. /)',
154
+ validate: value => {
155
+ global.baseIsNull = value.length === 0;
156
+ return true;
157
+ },
158
+ format: value => value.startsWith('/') ? value : \`/\${value}\`
159
+ },
160
+ {
161
+ type: () => global.baseIsNull ? 'text' : null,
162
+ name: 'BASE',
163
+ message: 'BASE_URL is required. It will default to "/"',
164
+ initial: '/',
165
+ format: value => value.startsWith('/') ? value : \`/\${value}\`
166
+ }
167
+ ], { onCancel });
168
+ console.log("");
169
+
170
+ const portalUrl = await prompts([
171
+ {
172
+ type: 'text',
173
+ name: 'PORTAL_URL',
174
+ message: 'Enter your Portal URL',
175
+ validate: value => {
176
+ global.portalUrlIsNull = value.length === 0;
177
+ return true;
178
+ }
179
+ },
180
+ {
181
+ // type: () => global.portalUrlIsNull ? 'text' : null,
182
+ // name: 'PORTAL_URL',
183
+ // message: 'portalUrl is required. If proceeding it\'ll be set to: ',
184
+ // initial: 'https://prof-services.maps.arcgis.com/',
185
+ }
186
+ ], { onCancel });
187
+ console.log("");
188
+
189
+ const webmapId = await prompts([
190
+ {
191
+ type: 'text',
192
+ name: 'WEBMAP_ID',
193
+ message: 'Enter your webmapId',
194
+ validate: value => {
195
+ global.webmapIdIsNull = value.length === 0;
196
+ return true;
197
+ }
198
+ }
199
+ ], { onCancel });
200
+ console.log("");
201
+
202
+ const appId = await prompts([
203
+ {
204
+ type: 'text',
205
+ name: 'APP_ID',
206
+ message: 'Enter your appId',
207
+ validate: value => {
208
+ global.appIdIsNull = value.length === 0;
209
+ return true;
210
+ }
211
+ }
212
+ ], { onCancel });
213
+ console.log("");
214
+
215
+ const arcGisApiKey = await prompts([
216
+ {
217
+ type: 'text',
218
+ name: 'ARC_GIS_API_KEY',
219
+ message: 'Enter your ArcGIS API key (optional)',
220
+ validate: value => {
221
+ global.arcGisApiKeyIsNull = value.length === 0;
222
+ return true;
223
+ }
224
+ }
225
+ ], { onCancel });
226
+ console.log("");
227
+
228
+ const arcGisClientId = await prompts([
229
+ {
230
+ type: 'text',
231
+ name: 'ARC_GIS_CLIENT_ID',
232
+ message: 'Enter your ArcGIS Client ID (optional)',
233
+ validate: value => {
234
+ global.arcGisClientIdIsNull = value.length === 0;
235
+ return true;
236
+ }
237
+ }
238
+ ], { onCancel });
239
+ console.log("");
240
+
241
+ const arcGisClientSecret = await prompts([
242
+ {
243
+ type: 'text',
244
+ name: 'ARC_GIS_CLIENT_SECRET',
245
+ message: 'Enter your ArcGIS Client Secret (optional)',
246
+ validate: value => {
247
+ global.arcGisClientSecretIsNull = value.length === 0;
248
+ return true;
249
+ }
250
+ }
251
+ ], { onCancel });
252
+ console.log("");
253
+
254
+ const securityClassification = await prompts([
255
+ {
256
+ type: 'select',
257
+ name: 'SECURITY_CLASSIFICATION',
258
+ message: 'Do you need the Security Classification bars above and below on the UI?',
259
+ choices: [
260
+ { title: 'None', value: false },
261
+ { title: 'Classified', value: 'classified' },
262
+ { title: 'Confidential', value: 'confidential' },
263
+ { title: 'Controlled Unclassified Information', value: 'controlled_unclassified_information' },
264
+ { title: 'Secret', value: 'secret' },
265
+ { title: 'Top Secret', value: 'top_secret' },
266
+ { title: 'Top Secret Sensitive Compartment Information', value: 'top_secret_sensitive_compartment_information' },
267
+ { title: 'Unclassified', value: 'unclassified' }
268
+ ],
269
+ validate: value => {
270
+ global.securityClassificationIsNull = value.length === 0;
271
+ return true;
272
+ }
273
+ },
274
+ {
275
+ type: () => global.securityClassificationIsNull ? 'text' : null,
276
+ name: 'SECURITY_CLASSIFICATION',
277
+ initial: false,
278
+ }
279
+ ], { onCancel });
280
+ console.log("");
281
+
282
+ const mapComponents = await prompts([
283
+ {
284
+ type: 'select',
285
+ name: 'MAP_COMPONENTS',
286
+ message: 'Do you want to use Map Components?',
287
+ choices: [
288
+ { title: 'Yes', value: true },
289
+ { title: 'No', value: false }
290
+ ],
291
+ validate: value => {
292
+ global.mapComponentsIsNull = value.length === 0;
293
+ return true;
294
+ }
295
+ }
296
+ ], { onCancel });
297
+ console.log("");
298
+
299
+ const calcite = await prompts([
300
+ {
301
+ type: 'select',
302
+ name: 'CALCITE',
303
+ message: 'Do you want to use Calcite Components?',
304
+ choices: [
305
+ { title: 'Yes', value: true },
306
+ { title: 'No', value: false }
307
+ ],
308
+ validate: value => {
309
+ global.calciteIsNull = value.length === 0;
310
+ return true;
311
+ }
312
+ }
313
+ ], { onCancel });
314
+ console.log("");
315
+
316
+ const demo = await prompts([
317
+ {
318
+ type: 'select',
319
+ name: 'DEMO',
320
+ message: 'Would you like a demo page?',
321
+ choices: [
322
+ { title: 'Yes', value: true },
323
+ { title: 'No', value: false }
324
+ ],
325
+ validate: value => {
326
+ global.demoIsNull = value.length === 0;
327
+ return true;
328
+ }
329
+ }
330
+ ], { onCancel });
331
+ console.log("");
332
+
333
+ // Detect package manager
334
+ const hasPnpmLock = fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'));
335
+ const hasYarnLock = fs.existsSync(path.join(process.cwd(), 'yarn.lock'));
336
+
337
+ let packageManager = 'npm';
338
+ if (hasPnpmLock) {
339
+ packageManager = 'pnpm';
340
+ } else if (hasYarnLock) {
341
+ packageManager = 'yarn';
342
+ }
343
+
344
+
345
+ // Install packages with loader
346
+ const initPromises = [];
347
+
348
+ if (mapComponents.MAP_COMPONENTS === true && calcite.CALCITE === true) {
349
+ console.log("πŸ“¦ Installing ArcGIS Core, Map Components, and Calcite Components...");
350
+ initPromises.push(
351
+ new Promise((resolve, reject) => {
352
+ exec(\`\${packageManager} install @arcgis/core@4.31.6 @arcgis/map-components@4.31.6 @esri/calcite-components@2.13.0\`, (error, stdout, stderr) => {
353
+ if (error) {
354
+ console.log('error:', chalk.white.bgRed(error.message));
355
+ reject(error);
356
+ } else {
357
+ resolve();
358
+ }
359
+ });
360
+ })
361
+ );
362
+ } else {
363
+ // Install just mapComponents?
364
+ if (mapComponents.MAP_COMPONENTS === true) {
365
+ console.log("πŸ“¦ Installing ArcGIS Core and Map Components...");
366
+ initPromises.push(
367
+ new Promise((resolve, reject) => {
368
+ exec(\`\${packageManager} install @arcgis/core@4.31.6 @arcgis/map-components@4.31.6\`, (error, stdout, stderr) => {
369
+ if (error) {
370
+ console.log('error:', chalk.white.bgRed(error.message));
371
+ reject(error);
372
+ } else {
373
+ resolve();
374
+ }
375
+ });
376
+ })
377
+ );
378
+ }
379
+
380
+ // Install just Calcite?
381
+ if (calcite.CALCITE === true) {
382
+ console.log("πŸ“¦ Installing Calcite Components...");
383
+ initPromises.push(
384
+ new Promise((resolve, reject) => {
385
+ exec(\`\${packageManager} install @esri/calcite-components@2.13.0\`, (error, stdout, stderr) => {
386
+ if (error) {
387
+ console.log('error:', chalk.white.bgRed(error.message));
388
+ reject(error);
389
+ } else {
390
+ resolve();
391
+ }
392
+ });
393
+ })
394
+ );
395
+ }
396
+ }
397
+
398
+ // Wait for all installations to complete
399
+ if (initPromises.length > 0) {
400
+ try {
401
+ await Promise.all(initPromises);
402
+ console.log("");
403
+ console.log("βœ… Package installation completed!");
404
+ } catch (error) {
405
+ console.log("");
406
+ console.log("❌ Package installation failed:", error.message);
407
+ }
408
+ }
409
+
410
+ // Add demo page?
411
+ if (demo.DEMO === true) {
412
+ // Create directory called 'arcgis' in './src/routes/'
413
+ const arcgisRouteDir = path.join(process.cwd(), 'src', 'routes', 'arcgis');
414
+ if (!fs.existsSync(arcgisRouteDir)) {
415
+ fs.mkdirSync(arcgisRouteDir, { recursive: true });
416
+ }
417
+
418
+ // Create a demo page within this directory called '+page.svelte'
419
+ const demoPagePath = path.join(arcgisRouteDir, '+page.svelte');
420
+
421
+ const demoPageContent = \`<script lang="ts">
422
+ // config
423
+ import config from "$lib/config";
424
+
425
+ // sk
426
+ import { onMount } from "svelte";
427
+ import { browser } from "$app/environment";
428
+ import { env } from "$env/dynamic/public";
429
+
430
+ // variables
431
+ let mapWrap: HTMLDivElement | null = $state(null);
432
+
433
+ onMount(() => {
434
+ console.log("env", env);
435
+ console.log("config", config);
436
+ console.log("mapWrap", mapWrap);
437
+ });
438
+
439
+ if (browser) {
440
+ import("@arcgis/map-components/dist/loader").then(
441
+ ({ defineCustomElements }) => {
442
+ defineCustomElements(window, {
443
+ resourcesUrl: "https://js.arcgis.com/map-components/4.31.6/assets",
444
+ });
445
+ }
446
+ );
447
+ }
448
+ </script>
449
+
450
+ <svelte:head>
451
+ <title>πŸ—ΊοΈ SV + ArcGIS Demo</title>
452
+ </svelte:head>
453
+
454
+ <main class="e-demo">
455
+ {#if config.SECURITY_CLASSIFICATION}
456
+ <div
457
+ class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
458
+ >
459
+ Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
460
+ </div>
461
+ {/if}
462
+ <div class="e-demo-container">
463
+ <div class="e-demo-header">
464
+ <h1>πŸ—ΊοΈ SV + ArcGIS Demo</h1>
465
+ </div>
466
+ <div class="e-demo-map-wrap" bind:this={mapWrap}>
467
+ <arcgis-map item-id="05e015c5f0314db9a487a9b46cb37eca">
468
+ <arcgis-zoom position="top-left"></arcgis-zoom>
469
+ </arcgis-map>
470
+ {#if config.CALCITE}
471
+ <calcite-button href="/" appearance="solid" scale="m">
472
+ Go Home
473
+ </calcite-button>
474
+ {/if}
475
+ </div>
476
+ </div>
477
+ {#if config.SECURITY_CLASSIFICATION}
478
+ <div
479
+ class="e-demo-security-bar e-demo-security-bar--{config.SECURITY_CLASSIFICATION}"
480
+ >
481
+ Security Classification: {config.SECURITY_CLASSIFICATION.toUpperCase()}
482
+ </div>
483
+ {/if}
484
+ </main>
485
+
486
+ <style>
487
+ @import "https://js.arcgis.com/4.31/@arcgis/core/assets/esri/themes/dark/main.css";
488
+ @import "@esri/calcite-components/dist/calcite/calcite.css";
489
+
490
+ :global(body:has(.e-demo)) {
491
+ margin: 0;
492
+ padding: 0;
493
+ height: 100%;
494
+ width: 100%;
495
+ background: #212121;
496
+ }
497
+
498
+ .e-demo {
499
+ display: grid;
500
+ grid-template-rows: 24px 1fr 24px;
501
+ height: 100vh;
502
+ }
503
+
504
+ .e-demo-container {
505
+ display: flex;
506
+ flex-direction: column;
507
+ align-items: center;
508
+ }
509
+
510
+ .e-demo-header {
511
+ padding: 1rem;
512
+ color: #f1f1f1;
513
+
514
+ translate: 0 0;
515
+ transition: translate 1s ease-out;
516
+
517
+ @starting-style {
518
+ translate: 0 -4px;
519
+ }
520
+ }
521
+
522
+ .e-demo-map-wrap {
523
+ display: flex;
524
+ flex-direction: column;
525
+ gap: 2rem;
526
+ width: 50vmax;
527
+ height: 100vh;
528
+ margin-inline: auto;
529
+ margin: 0;
530
+ padding: 0;
531
+ padding-block-end: 2rem;
532
+
533
+ & arcgis-map {
534
+ width: 100%;
535
+ height: 50vh;
536
+
537
+ opacity: 1;
538
+ transition: opacity 2s ease-out;
539
+
540
+ @starting-style {
541
+ opacity: 0;
542
+ }
543
+ }
544
+
545
+ & calcite-button {
546
+ align-self: center;
547
+ }
548
+ }
549
+
550
+ .e-demo-security-bar {
551
+ position: sticky;
552
+ display: flex;
553
+ align-items: center;
554
+ justify-content: center;
555
+ inset-block-start: 0;
556
+ height: 22px;
557
+ background-color: #000;
558
+ color: #fff;
559
+ margin: 0;
560
+ font-size: 14px;
561
+ z-index: 1;
562
+
563
+ &:not(:first-of-type) {
564
+ inset-block-end: 0;
565
+ }
566
+
567
+ &.e-demo-security-bar--classified {
568
+ color: #fff;
569
+ background-color: #723d9a;
570
+ }
571
+ &.e-demo-security-bar--confidential {
572
+ color: #fff;
573
+ background-color: #0033a0;
574
+ }
575
+ &.e-demo-security-bar--controlled_unclassified_information {
576
+ color: #fff;
577
+ background-color: #3d1e5a;
578
+ }
579
+ &.e-demo-security-bar--secret {
580
+ color: #fff;
581
+ background-color: #c8102e;
582
+ }
583
+ &.e-demo-security-bar--top_secret {
584
+ color: #000;
585
+ background-color: #ff671f;
586
+ }
587
+ &.e-demo-security-bar--top_secret_sensitive_compartment_information {
588
+ color: #000;
589
+ background-color: #f7ea48;
590
+ }
591
+ &.e-demo-security-bar--unclassified {
592
+ color: #fff;
593
+ background-color: #007a33;
594
+ }
595
+ }
596
+ </style>
597
+ \`;
598
+
599
+ fs.writeFileSync(demoPagePath, demoPageContent);
600
+ console.log(\`βœ… Created demo page at ./src/routes/arcgis/+page.svelte\`);
601
+
602
+ // Update root page with link to demo
603
+ const rootRouteDir = path.join(process.cwd(), 'src', 'routes');
604
+ const rootPagePath = path.join(rootRouteDir, '+page.svelte');
605
+ const rootPageUpdate = \`<p>Visit the <a href="arcgis">arcgis demo page</a> and view console.log output</p>\`;
606
+
607
+ // Read existing root page content and append the demo link
608
+ if (fs.existsSync(rootPagePath)) {
609
+ const existingContent = fs.readFileSync(rootPagePath, 'utf8');
610
+ if (!existingContent.includes('arcgis demo page')) {
611
+ const updatedContent = existingContent + \`\n\` + rootPageUpdate;
612
+ fs.writeFileSync(rootPagePath, updatedContent);
613
+ }
614
+ console.log(\`βœ… Updated homepage with demo link\`);
615
+ }
616
+ }
617
+
618
+ const config = {
619
+ VERSION,
620
+ ...appName,
621
+ ...base,
622
+ ...portalUrl,
623
+ ...webmapId,
624
+ ...appId,
625
+ ...securityClassification,
626
+ ...mapComponents,
627
+ ...calcite
628
+ }
629
+
630
+ const env = \`ARC_GIS_API_KEY=\${arcGisApiKey.ARC_GIS_API_KEY}
631
+ ARC_GIS_CLIENT_SECRET=\${arcGisClientSecret.ARC_GIS_CLIENT_SECRET}
632
+ PUBLIC_ARC_GIS_CLIENT_ID=\${arcGisClientId.ARC_GIS_CLIENT_ID}\`;
633
+
634
+ const envExample = \`# ARC_GIS_API_KEY=
635
+ # ARC_GIS_CLIENT_SECRET=
636
+ # PUBLIC_ARC_GIS_CLIENT_ID=\`;
637
+
638
+ // Ensure the config directory exists
639
+ const configDir = path.join(process.cwd(), 'src', 'lib', 'config');
640
+ if (!fs.existsSync(configDir)) {
641
+ fs.mkdirSync(configDir, { recursive: true });
642
+ }
643
+
644
+ // Create proper JavaScript module content
645
+ const configContent = \`\${JSON.stringify(config, null, 2)}\`;
646
+ const envContent = env;
647
+ fs.writeFileSync(configPath, configContent);
648
+ fs.writeFileSync(envPath, envContent);
649
+ fs.writeFileSync(envExamplePath, envExample);
650
+
651
+ return {
652
+ config,
653
+ env
654
+ };
655
+ }
656
+
657
+ // Execute, log, handle errors
658
+ generateConfig()
659
+ .then(data => {
660
+
661
+ if (data) {
662
+ if (data.config) {
663
+ // Check if typescript is used
664
+ const configFilePath = usesTypeScript ? './src/lib/config/index.ts' : './src/lib/config/index.js';
665
+
666
+ // Create and write to config file
667
+ const configFileText = \`export default \${JSON.stringify(data.config, null, 2)}\`;
668
+ fs.writeFileSync(configFilePath, configFileText, { encoding: 'utf8', flag: 'w' });
669
+
670
+ // Show that config was written
671
+ console.log(\`βœ… Updated \` + chalk.bold(\`/src/lib/config/index.\${usesTypeScript ? 'ts' : 'js'}\`));
672
+ }
673
+
674
+ if (!global.arcGisApiKeyIsNull || !global.arcGisClientIdIsNull || !global.arcGisClientSecretIsNull) {
675
+ const envFilePath = path.join(process.cwd(), \`.env\`);
676
+ const envFileText = data.env;
677
+ fs.writeFileSync(envFilePath, envFileText, { encoding: 'utf8', flag: 'w' });
678
+
679
+ // Show that env was written
680
+ console.log(\`βœ… Updated \` + chalk.bold(\`.env\`));
681
+ console.log(\`πŸ‘€ Tip: Make sure your .gitignore has the line: .env\`);
682
+ }
683
+
684
+ // Show that generation was successful
685
+ console.log("");
686
+ console.log('πŸ”₯ Welcome to your ' + chalk.white.bgBlue('ArcGIS') + ' + ' + chalk.white.bgRed('SvelteKit') + ' app');
687
+
688
+ // Detect package manager
689
+ const hasPnpmLock = fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'));
690
+ const hasYarnLock = fs.existsSync(path.join(process.cwd(), 'yarn.lock'));
691
+
692
+ if (hasPnpmLock) {
693
+ console.log('πŸ‘‰ Now you can run \`' + chalk.white.green('pnpm run dev') + '\`');
694
+ } else if (hasYarnLock) {
695
+ console.log('πŸ‘‰ Now you can run \`' + chalk.white.green('yarn run dev') + '\`');
696
+ } else {
697
+ console.log('πŸ‘‰ Now you can run \`' + chalk.white.green('npm run dev') + '\`');
698
+ }
699
+
700
+ }
701
+
702
+ })
703
+ .catch(err => console.error('Error generating configuration:', err));
704
+ `;
705
+
706
+ fs.writeFileSync(initConfigPath, initConfigContent);
707
+ console.log("βœ… Created .config/init-sv-arcgis.js");
708
+
709
+ // Add script
710
+ if (!packageJson.scripts) packageJson.scripts = {};
711
+ packageJson.scripts.config = 'SUPPRESS_NO_CONFIG_WARNING=true node ./.config/init-sv-arcgis.js';
712
+
713
+ // Write back to package.json
714
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
715
+
716
+ console.log("βœ… Added config script to package.json");
717
+ console.log("");
718
+
719
+ console.log("1️⃣ Please install required dependencies:");
720
+ if (packageManager === 'pnpm') {
721
+ console.log(" pnpm add chalk cross-env prompts");
722
+ console.log("");
723
+
724
+ console.log("2️⃣ Then run:");
725
+ console.log(" pnpm run config");
726
+ } else if (packageManager === 'yarn') {
727
+ console.log(" yarn add chalk cross-env prompts");
728
+ console.log("");
729
+
730
+ console.log("2️⃣ Then run:");
731
+ console.log(" yarn run config");
732
+ } else {
733
+ console.log(" npm install --save chalk cross-env prompts");
734
+ console.log("");
735
+
736
+ console.log("2️⃣ Then run:");
737
+ console.log(" npm run config");
738
+ }
package/index.js ADDED
@@ -0,0 +1 @@
1
+ // console.log('Thanks for installing sv-arcgis');
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "sv-arcgis",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "bin": {
6
+ "sv-arcgis": "./bin/sv-arcgis-setup.js"
7
+ },
8
+ "scripts": {
9
+ "sematice-release": "semantic-release"
10
+ },
11
+ "keywords": [
12
+ "arcgis",
13
+ "sveltekit",
14
+ "svelte",
15
+ "cli",
16
+ "setup",
17
+ "scaffold",
18
+ "generator",
19
+ "esri",
20
+ "gis",
21
+ "mapping",
22
+ "geospatial",
23
+ "development",
24
+ "configuration",
25
+ "boilerplate",
26
+ "template"
27
+ ],
28
+ "author": "Joe Allen",
29
+ "license": "MIT",
30
+ "description": "a CLI tool that guides you through setting up a ArcGIS / SvelteKit development environment.",
31
+ "devDependencies": {
32
+ "semantic-release": "^24.2.7"
33
+ },
34
+ "files": [
35
+ "bin",
36
+ "README.md",
37
+ "CHANGELOG.md",
38
+ "LICENSE"
39
+ ]
40
+ }