sv-arcgis 1.3.0-next.1 β 1.3.0-next.3
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 +8 -7
- package/bin/sv-arcgis-setup.js +39 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
## π¬ Prereqs
|
|
2
2
|
|
|
3
|
-
- SvelteKit
|
|
3
|
+
- SvelteKit: `npx sv create [project_name]`
|
|
4
|
+
- (Or Svelte: `npm create vite@latest`)
|
|
4
5
|
|
|
5
6
|
## ποΈ Setup
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
1. Install [sv-arcgis](https://www.npmjs.com/package/sv-arcgis) `npx sv-arcgis`
|
|
9
|
+
2. Follow instructions in terminal π
|
|
9
10
|
|
|
10
11
|
## π Notes
|
|
11
12
|
|
|
@@ -15,10 +16,10 @@
|
|
|
15
16
|
|
|
16
17
|
## πΊοΈ Roadmap
|
|
17
18
|
|
|
18
|
-
- Option for / intergrate OAuth2 https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/arcgis-apis/
|
|
19
|
-
- Update to use determine if Svelte Vite app? (Demo would need to be different)
|
|
20
|
-
- Create tests (see https://www.youtube.com/watch?v=Xk8yaN9_PZA)
|
|
21
19
|
- Create CI / CD (w/ tests)
|
|
20
|
+
- Create tests (see https://www.youtube.com/watch?v=Xk8yaN9_PZA)
|
|
21
|
+
- Option for / intergrate OAuth2 https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/arcgis-apis/
|
|
22
|
+
- [x] Update to work Svelte / Vite app (not just Kit)? (Demo would need to be different)
|
|
22
23
|
|
|
23
24
|
## π Help
|
|
24
25
|
|
package/bin/sv-arcgis-setup.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const fs = require(
|
|
3
|
-
const path = require(
|
|
4
|
-
const { execSync } = require(
|
|
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(),
|
|
6
|
+
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
7
7
|
|
|
8
8
|
if (!fs.existsSync(packageJsonPath)) {
|
|
9
|
-
console.error(
|
|
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,
|
|
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(),
|
|
17
|
-
const hasYarnLock = fs.existsSync(path.join(process.cwd(),
|
|
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 =
|
|
19
|
+
let packageManager = "npm";
|
|
20
20
|
if (hasPnpmLock) {
|
|
21
|
-
packageManager =
|
|
21
|
+
packageManager = "pnpm";
|
|
22
22
|
} else if (hasYarnLock) {
|
|
23
|
-
packageManager =
|
|
23
|
+
packageManager = "yarn";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// Create config directory
|
|
27
|
-
const configDirectory = path.join(process.cwd(),
|
|
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,
|
|
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';
|
|
@@ -333,7 +333,7 @@ if (calcite.CALCITE === true) {
|
|
|
333
333
|
console.log("π¦ Installing ArcGIS Core, Map Components, and Calcite Components...");
|
|
334
334
|
initPromises.push(
|
|
335
335
|
new Promise((resolve, reject) => {
|
|
336
|
-
exec(\`\${packageManager} install @arcgis/core@4.33.
|
|
336
|
+
exec(\`\${packageManager} install @arcgis/core@4.33.14 @arcgis/map-components@4.33.24 @esri/calcite-components@3.3.3\`, (error, stdout, stderr) => {
|
|
337
337
|
if (error) {
|
|
338
338
|
console.log('error:', chalk.white.bgRed(error.message));
|
|
339
339
|
reject(error);
|
|
@@ -347,7 +347,7 @@ if (calcite.CALCITE === true) {
|
|
|
347
347
|
console.log("π¦ Installing ArcGIS Core and Map Components...");
|
|
348
348
|
initPromises.push(
|
|
349
349
|
new Promise((resolve, reject) => {
|
|
350
|
-
exec(\`\${packageManager} install @arcgis/core@4.33.
|
|
350
|
+
exec(\`\${packageManager} install @arcgis/core@4.33.14 @arcgis/map-components@4.33.24\`, (error, stdout, stderr) => {
|
|
351
351
|
if (error) {
|
|
352
352
|
console.log('error:', chalk.white.bgRed(error.message));
|
|
353
353
|
reject(error);
|
|
@@ -368,6 +368,8 @@ if (initPromises.length > 0) {
|
|
|
368
368
|
} catch (error) {
|
|
369
369
|
console.log("");
|
|
370
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.");
|
|
371
373
|
}
|
|
372
374
|
}
|
|
373
375
|
|
|
@@ -417,7 +419,7 @@ if (demo.DEMO === true) {
|
|
|
417
419
|
import("@arcgis/map-components/dist/loader").then(
|
|
418
420
|
({ defineCustomElements }) => {
|
|
419
421
|
defineCustomElements(window, {
|
|
420
|
-
resourcesUrl: "https://js.arcgis.com/map-components/4.33.
|
|
422
|
+
resourcesUrl: "https://js.arcgis.com/map-components/4.33.24/assets",
|
|
421
423
|
});
|
|
422
424
|
}
|
|
423
425
|
);
|
|
@@ -461,7 +463,7 @@ if (demo.DEMO === true) {
|
|
|
461
463
|
</main>
|
|
462
464
|
|
|
463
465
|
<style>
|
|
464
|
-
@import "https://js.arcgis.com/4.
|
|
466
|
+
@import "https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/dark/main.css";\${calcite.CALCITE ? '\\n @import "@esri/calcite-components/dist/calcite/calcite.css";' : ''}
|
|
465
467
|
|
|
466
468
|
:global(body:has(.e-demo)) {
|
|
467
469
|
margin: 0;
|
|
@@ -592,7 +594,7 @@ if (demo.DEMO === true) {
|
|
|
592
594
|
import("@arcgis/map-components/dist/loader").then(
|
|
593
595
|
({ defineCustomElements }) => {
|
|
594
596
|
defineCustomElements(window, {
|
|
595
|
-
resourcesUrl: "https://js.arcgis.com/map-components/4.33.
|
|
597
|
+
resourcesUrl: "https://js.arcgis.com/map-components/4.33.24/assets",
|
|
596
598
|
});
|
|
597
599
|
}
|
|
598
600
|
);
|
|
@@ -635,7 +637,7 @@ if (demo.DEMO === true) {
|
|
|
635
637
|
</main>
|
|
636
638
|
|
|
637
639
|
<style>
|
|
638
|
-
@import "https://js.arcgis.com/4.
|
|
640
|
+
@import "https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/dark/main.css";\${calcite.CALCITE ? '\\n @import "@esri/calcite-components/dist/calcite/calcite.css";' : ''}
|
|
639
641
|
|
|
640
642
|
:global(body:has(.e-demo)) {
|
|
641
643
|
margin: 0;
|
|
@@ -749,7 +751,7 @@ if (demo.DEMO === true) {
|
|
|
749
751
|
|
|
750
752
|
fs.writeFileSync(demoPagePath, demoPageContent);
|
|
751
753
|
if (isSvelte) {
|
|
752
|
-
console.log(\`β
Created demo page at ./src/
|
|
754
|
+
console.log(\`β
Created demo page at ./src/lib/arcgis/ArcGIS.svelte\`);
|
|
753
755
|
} else {
|
|
754
756
|
console.log(\`β
Created demo page at ./src/routes/arcgis/+page.svelte\`);
|
|
755
757
|
}
|
|
@@ -757,7 +759,7 @@ if (demo.DEMO === true) {
|
|
|
757
759
|
// Update root page
|
|
758
760
|
const rootRouteDir = isSvelte ? path.join(process.cwd(), 'src') : path.join(process.cwd(), 'src', 'routes');
|
|
759
761
|
const rootPagePath = isSvelte ? path.join(rootRouteDir, 'App.svelte') : path.join(rootRouteDir, '+page.svelte');
|
|
760
|
-
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>\`;
|
|
762
|
+
const rootPageUpdate = isSvelte ? \n\`import ArcGIS from './lib/ArcGIS.svelte';\` : \`<p>Visit the <a href="arcgis">arcgis demo page</a> and view console.log output</p>\`;
|
|
761
763
|
|
|
762
764
|
// Read existing root page content and append the demo link
|
|
763
765
|
if (fs.existsSync(rootPagePath) && isSvelteKit) {
|
|
@@ -878,7 +880,8 @@ console.log("β
Created .config/init-sv-arcgis.js");
|
|
|
878
880
|
|
|
879
881
|
// Add script
|
|
880
882
|
if (!packageJson.scripts) packageJson.scripts = {};
|
|
881
|
-
packageJson.scripts.config =
|
|
883
|
+
packageJson.scripts.config =
|
|
884
|
+
"SUPPRESS_NO_CONFIG_WARNING=true node ./.config/init-sv-arcgis.js";
|
|
882
885
|
|
|
883
886
|
// Write back to package.json
|
|
884
887
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
@@ -887,12 +890,19 @@ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
|
887
890
|
console.log("π¦ Installing required dependencies...");
|
|
888
891
|
|
|
889
892
|
try {
|
|
890
|
-
if (packageManager ===
|
|
891
|
-
execSync(
|
|
892
|
-
|
|
893
|
-
|
|
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
|
+
});
|
|
894
901
|
} else {
|
|
895
|
-
execSync(
|
|
902
|
+
execSync(
|
|
903
|
+
"npm install --save-dev chalk@5.4.1 prompts@2.4.2 cross-env@10.0.0",
|
|
904
|
+
{ stdio: "inherit" }
|
|
905
|
+
);
|
|
896
906
|
}
|
|
897
907
|
console.log("β
Dependencies installed successfully");
|
|
898
908
|
} catch (error) {
|
|
@@ -904,9 +914,9 @@ console.log("β
Added config script to package.json");
|
|
|
904
914
|
console.log("");
|
|
905
915
|
|
|
906
916
|
console.log("π Now run:");
|
|
907
|
-
if (packageManager ===
|
|
917
|
+
if (packageManager === "pnpm") {
|
|
908
918
|
console.log(" `pnpm run config`");
|
|
909
|
-
} else if (packageManager ===
|
|
919
|
+
} else if (packageManager === "yarn") {
|
|
910
920
|
console.log(" `yarn run config`");
|
|
911
921
|
} else {
|
|
912
922
|
console.log(" `npm run config`");
|