create-swdg-frontend 0.1.7 → 0.2.1
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 +31 -13
- package/bin/index.js +3 -244
- package/lib/argv.js +43 -0
- package/lib/cli.js +141 -0
- package/lib/constants.js +24 -0
- package/lib/gis.js +92 -0
- package/lib/manifest.js +23 -0
- package/lib/prompts.js +55 -0
- package/lib/scaffold.js +118 -0
- package/package.json +6 -2
- package/scripts/sync-template.js +120 -0
- package/scripts/validate-template.mjs +74 -0
- package/stubs/tsconfig.node.json +11 -0
- package/stubs/types-env.d.ts +9 -0
- package/stubs/vite.config.ts +64 -0
- package/template/.env.example +6 -0
- package/template/.github/workflows/ci.yml +23 -0
- package/template/.github/workflows/release.yml +69 -0
- package/template/.stylelintrc.json +7 -1
- package/template/README.md +95 -32
- package/template/auto-imports.d.ts +10 -0
- package/template/docs/MAINTAINER.md +75 -0
- package/template/docs/ONBOARDING.md +284 -0
- package/template/docs/TESTING.md +104 -0
- package/template/package.json +48 -41
- package/template/pnpm-lock.yaml +6360 -0
- package/template/scripts/gen-api.cjs +20 -7
- package/template/scripts/release.mjs +22 -28
- package/template/scripts/set-release-version.mjs +46 -0
- package/template/scripts/test-pipeline.mjs +85 -0
- package/template/scripts/test-scaffold.mjs +197 -0
- package/template/scripts/test-template.mjs +52 -0
- package/template/scripts/verify.mjs +28 -0
- package/template/scripts/vite-plugin-cesium-dev.ts +56 -0
- package/template/src/api/README.md +4 -0
- package/template/src/components/Body/index.vue +65 -35
- package/template/src/components/CesiumViewer/index.vue +36 -0
- package/template/src/components/Header/index.vue +16 -5
- package/template/src/components/OnboardingDeck/index.vue +449 -0
- package/template/src/data/onboardingSlides.ts +208 -0
- package/template/src/main.ts +1 -0
- package/template/src/router/index.ts +20 -14
- package/template/src/router/routeUtils.ts +13 -0
- package/template/src/styles/shell.css +232 -0
- package/template/src/utils/axios-middleware.js +1 -1
- package/template/src/utils/cesium/index.ts +71 -0
- package/template/src/utils/composables/useFeatureGis.ts +24 -0
- package/template/src/views/examples/cesium/index.vue +85 -0
- package/template/src/views/examples/guide/index.vue +42 -0
- package/template/src/views/examples/test/index.vue +63 -0
- package/template/src/views/index.vue +2 -3
- package/template/tests/README.md +1 -0
- package/template/tests/unit/onboardingSlides.test.ts +20 -0
- package/template/tests/unit/router.utils.test.ts +21 -0
- package/template/tests/unit/scaffold.lib.test.ts +44 -0
- package/template/tests/unit/useFeatureGis.test.ts +14 -0
- package/template/tsconfig.json +17 -17
- package/template/tsconfig.node.json +1 -1
- package/template/types/env.d.ts +13 -0
- package/template/vite.config.ts +26 -5
- package/template/vitest.config.ts +13 -0
- package/template/.env +0 -1
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_0.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_1.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_10.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_11.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_12.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_13.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_14.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_15.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_16.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_17.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_18.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_19.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_2.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_20.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_21.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_22.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_23.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_24.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_25.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_26.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_27.json +0 -438
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_3.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_4.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_5.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_6.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_7.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_8.json +0 -1012
- package/template/public/Cesium1.119/Assets/IAU2006_XYS/IAU2006_XYS_9.json +0 -1012
- package/template/public/Cesium1.119/Assets/Images/bing_maps_credit.png +0 -0
- package/template/public/Cesium1.119/Assets/Images/cesium_credit.png +0 -0
- package/template/public/Cesium1.119/Assets/Images/google_earth_credit.png +0 -0
- package/template/public/Cesium1.119/Assets/Images/ion-credit.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/LensFlare/DirtMask.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/LensFlare/StarBurst.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/0/0/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/0/1/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/0/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/0/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/1/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/1/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/2/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/2/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/3/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/1/3/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/0/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/0/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/0/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/0/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/1/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/1/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/1/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/1/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/2/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/2/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/2/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/2/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/3/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/3/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/3/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/3/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/4/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/4/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/4/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/4/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/5/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/5/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/5/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/5/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/6/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/6/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/6/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/6/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/7/0.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/7/1.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/7/2.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/2/7/3.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/NaturalEarthII/tilemapresource.xml +0 -14
- package/template/public/Cesium1.119/Assets/Textures/SkyBox/tycho2t3_80_mx.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/SkyBox/tycho2t3_80_my.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/SkyBox/tycho2t3_80_mz.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/SkyBox/tycho2t3_80_px.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/SkyBox/tycho2t3_80_py.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/SkyBox/tycho2t3_80_pz.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/airfield.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/airport.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/alcohol-shop.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/america-football.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/art-gallery.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/bakery.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/bank.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/bar.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/baseball.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/basketball.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/beer.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/bicycle.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/building.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/bus.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/cafe.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/camera.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/campsite.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/car.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/cemetery.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/cesium.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/chemist.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/cinema.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/circle-stroked.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/circle.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/city.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/clothing-store.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/college.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/commercial.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/cricket.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/cross.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/dam.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/danger.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/disability.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/dog-park.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/embassy.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/emergency-telephone.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/entrance.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/farm.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/fast-food.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/ferry.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/fire-station.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/fuel.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/garden.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/gift.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/golf.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/grocery.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/hairdresser.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/harbor.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/heart.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/heliport.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/hospital.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/ice-cream.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/industrial.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/land-use.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/laundry.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/library.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/lighthouse.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/lodging.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/logging.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/london-underground.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/marker-stroked.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/marker.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/minefield.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/mobilephone.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/monument.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/museum.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/music.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/oil-well.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/park.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/park2.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/parking-garage.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/parking.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/pharmacy.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/pitch.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/place-of-worship.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/playground.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/police.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/polling-place.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/post.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/prison.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/rail-above.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/rail-light.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/rail-metro.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/rail-underground.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/rail.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/religious-christian.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/religious-jewish.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/religious-muslim.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/restaurant.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/roadblock.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/rocket.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/school.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/scooter.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/shop.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/skiing.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/slaughterhouse.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/soccer.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/square-stroked.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/square.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/star-stroked.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/star.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/suitcase.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/swimming.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/telephone.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/tennis.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/theatre.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/toilets.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/town-hall.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/town.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/triangle-stroked.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/triangle.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/village.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/warehouse.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/waste-basket.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/water.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/wetland.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/maki/zoo.png +0 -0
- package/template/public/Cesium1.119/Assets/Textures/moonSmall.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/pin.svg +0 -1
- package/template/public/Cesium1.119/Assets/Textures/waterNormals.jpg +0 -0
- package/template/public/Cesium1.119/Assets/Textures/waterNormalsSmall.jpg +0 -0
- package/template/public/Cesium1.119/Assets/approximateTerrainHeights.json +0 -10924
- package/template/public/Cesium1.119/Cesium.js +0 -185772
- package/template/public/Cesium1.119/ThirdParty/Workers/package.json +0 -3
- package/template/public/Cesium1.119/ThirdParty/Workers/pako_deflate.min.js +0 -1681
- package/template/public/Cesium1.119/ThirdParty/Workers/pako_inflate.min.js +0 -1489
- package/template/public/Cesium1.119/ThirdParty/Workers/z-worker-pako.js +0 -1070
- package/template/public/Cesium1.119/ThirdParty/basis_transcoder.wasm +0 -0
- package/template/public/Cesium1.119/ThirdParty/draco_decoder.wasm +0 -0
- package/template/public/Cesium1.119/ThirdParty/google-earth-dbroot-parser.js +0 -11424
- package/template/public/Cesium1.119/Widgets/Animation/Animation.css +0 -127
- package/template/public/Cesium1.119/Widgets/Animation/lighter.css +0 -78
- package/template/public/Cesium1.119/Widgets/BaseLayerPicker/BaseLayerPicker.css +0 -112
- package/template/public/Cesium1.119/Widgets/BaseLayerPicker/lighter.css +0 -28
- package/template/public/Cesium1.119/Widgets/Cesium3DTilesInspector/Cesium3DTilesInspector.css +0 -104
- package/template/public/Cesium1.119/Widgets/CesiumInspector/CesiumInspector.css +0 -115
- package/template/public/Cesium1.119/Widgets/CesiumWidget/CesiumWidget.css +0 -119
- package/template/public/Cesium1.119/Widgets/CesiumWidget/lighter.css +0 -14
- package/template/public/Cesium1.119/Widgets/FullscreenButton/FullscreenButton.css +0 -8
- package/template/public/Cesium1.119/Widgets/Geocoder/Geocoder.css +0 -72
- package/template/public/Cesium1.119/Widgets/Geocoder/lighter.css +0 -17
- package/template/public/Cesium1.119/Widgets/I3SBuildingSceneLayerExplorer/I3SBuildingSceneLayerExplorer.css +0 -27
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldHillshade.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldImagery.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/ArcGisMapServiceWorldOcean.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/bingAerial.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/bingAerialLabels.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/bingRoads.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/blueMarble.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/earthAtNight.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/mapQuestOpenStreetMap.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/mapboxSatellite.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/mapboxStreets.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/mapboxTerrain.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/naturalEarthII.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/openStreetMap.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/sentinel-2.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/stadiaAlidadeSmooth.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/stadiaAlidadeSmoothDark.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/stamenToner.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/ImageryProviders/stamenWatercolor.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/Mouse.svg +0 -84
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/MouseLeft.svg +0 -76
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/MouseMiddle.svg +0 -76
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/MouseRight.svg +0 -76
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/Touch.svg +0 -120
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/TouchDrag.svg +0 -129
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/TouchRotate.svg +0 -76
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/TouchTilt.svg +0 -135
- package/template/public/Cesium1.119/Widgets/Images/NavigationHelp/TouchZoom.svg +0 -74
- package/template/public/Cesium1.119/Widgets/Images/TerrainProviders/CesiumWorldTerrain.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/TerrainProviders/Ellipsoid.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/TimelineIcons.png +0 -0
- package/template/public/Cesium1.119/Widgets/Images/info-loading.gif +0 -0
- package/template/public/Cesium1.119/Widgets/InfoBox/InfoBox.css +0 -94
- package/template/public/Cesium1.119/Widgets/InfoBox/InfoBoxDescription.css +0 -178
- package/template/public/Cesium1.119/Widgets/NavigationHelpButton/NavigationHelpButton.css +0 -95
- package/template/public/Cesium1.119/Widgets/NavigationHelpButton/lighter.css +0 -38
- package/template/public/Cesium1.119/Widgets/PerformanceWatchdog/PerformanceWatchdog.css +0 -15
- package/template/public/Cesium1.119/Widgets/ProjectionPicker/ProjectionPicker.css +0 -46
- package/template/public/Cesium1.119/Widgets/SceneModePicker/SceneModePicker.css +0 -72
- package/template/public/Cesium1.119/Widgets/SelectionIndicator/SelectionIndicator.css +0 -22
- package/template/public/Cesium1.119/Widgets/Timeline/Timeline.css +0 -103
- package/template/public/Cesium1.119/Widgets/Timeline/lighter.css +0 -18
- package/template/public/Cesium1.119/Widgets/VRButton/VRButton.css +0 -8
- package/template/public/Cesium1.119/Widgets/Viewer/Viewer.css +0 -107
- package/template/public/Cesium1.119/Widgets/VoxelInspector/VoxelInspector.css +0 -18
- package/template/public/Cesium1.119/Widgets/lighter.css +0 -246
- package/template/public/Cesium1.119/Widgets/lighterShared.css +0 -46
- package/template/public/Cesium1.119/Widgets/shared.css +0 -103
- package/template/public/Cesium1.119/Widgets/widgets.css +0 -1376
- package/template/public/Cesium1.119/Workers/chunk-3C7WC463.js +0 -611
- package/template/public/Cesium1.119/Workers/chunk-3JW36LZF.js +0 -166
- package/template/public/Cesium1.119/Workers/chunk-4BTGX3WJ.js +0 -264
- package/template/public/Cesium1.119/Workers/chunk-4WRMLZA7.js +0 -128
- package/template/public/Cesium1.119/Workers/chunk-7Z5IIKOJ.js +0 -8046
- package/template/public/Cesium1.119/Workers/chunk-ABGXSJNX.js +0 -341
- package/template/public/Cesium1.119/Workers/chunk-AMQUWUD4.js +0 -269
- package/template/public/Cesium1.119/Workers/chunk-ATPDRNKI.js +0 -28
- package/template/public/Cesium1.119/Workers/chunk-BMHPVZ4H.js +0 -199
- package/template/public/Cesium1.119/Workers/chunk-CBEO3SHS.js +0 -1102
- package/template/public/Cesium1.119/Workers/chunk-CV7DLCWG.js +0 -485
- package/template/public/Cesium1.119/Workers/chunk-DQO6B4EQ.js +0 -76
- package/template/public/Cesium1.119/Workers/chunk-ED3TLP6D.js +0 -91
- package/template/public/Cesium1.119/Workers/chunk-EFZKO5RU.js +0 -42
- package/template/public/Cesium1.119/Workers/chunk-F5IHREXR.js +0 -2678
- package/template/public/Cesium1.119/Workers/chunk-FKRG4HDY.js +0 -516
- package/template/public/Cesium1.119/Workers/chunk-FYOYUPXG.js +0 -399
- package/template/public/Cesium1.119/Workers/chunk-GFN7NNSJ.js +0 -65
- package/template/public/Cesium1.119/Workers/chunk-HEEMUCG6.js +0 -92
- package/template/public/Cesium1.119/Workers/chunk-HSWA4OEL.js +0 -672
- package/template/public/Cesium1.119/Workers/chunk-IAC5XVZV.js +0 -287
- package/template/public/Cesium1.119/Workers/chunk-II4VNKYR.js +0 -50
- package/template/public/Cesium1.119/Workers/chunk-ILGBPNP6.js +0 -28
- package/template/public/Cesium1.119/Workers/chunk-IRH46BDL.js +0 -124
- package/template/public/Cesium1.119/Workers/chunk-IUA6FAOZ.js +0 -31
- package/template/public/Cesium1.119/Workers/chunk-K4ASOM65.js +0 -331
- package/template/public/Cesium1.119/Workers/chunk-KCIZBVXL.js +0 -258
- package/template/public/Cesium1.119/Workers/chunk-KF5NF354.js +0 -162
- package/template/public/Cesium1.119/Workers/chunk-KRKI6AAO.js +0 -773
- package/template/public/Cesium1.119/Workers/chunk-KZNJOCYU.js +0 -162
- package/template/public/Cesium1.119/Workers/chunk-O5IJ3OGP.js +0 -857
- package/template/public/Cesium1.119/Workers/chunk-OO23RBLX.js +0 -183
- package/template/public/Cesium1.119/Workers/chunk-P37AI2DW.js +0 -85
- package/template/public/Cesium1.119/Workers/chunk-PDMQLSBL.js +0 -108
- package/template/public/Cesium1.119/Workers/chunk-PEYJTJPE.js +0 -73
- package/template/public/Cesium1.119/Workers/chunk-POASMU2N.js +0 -2372
- package/template/public/Cesium1.119/Workers/chunk-PXCJYT2S.js +0 -73
- package/template/public/Cesium1.119/Workers/chunk-Q6L7X3LP.js +0 -538
- package/template/public/Cesium1.119/Workers/chunk-QB3MDM4J.js +0 -1670
- package/template/public/Cesium1.119/Workers/chunk-R6KGAEF6.js +0 -392
- package/template/public/Cesium1.119/Workers/chunk-RXTBM4OI.js +0 -57
- package/template/public/Cesium1.119/Workers/chunk-SB224QGV.js +0 -72
- package/template/public/Cesium1.119/Workers/chunk-T6BE4RZK.js +0 -37
- package/template/public/Cesium1.119/Workers/chunk-TAMCUKAR.js +0 -814
- package/template/public/Cesium1.119/Workers/chunk-TMSETF7M.js +0 -579
- package/template/public/Cesium1.119/Workers/chunk-TOGHF3VN.js +0 -376
- package/template/public/Cesium1.119/Workers/chunk-UH2WFNTA.js +0 -111
- package/template/public/Cesium1.119/Workers/chunk-V7JEDBOE.js +0 -573
- package/template/public/Cesium1.119/Workers/chunk-VBIROZR5.js +0 -633
- package/template/public/Cesium1.119/Workers/chunk-W23CU777.js +0 -271
- package/template/public/Cesium1.119/Workers/chunk-X5IHHI6X.js +0 -173
- package/template/public/Cesium1.119/Workers/chunk-XHX2UPDO.js +0 -217
- package/template/public/Cesium1.119/Workers/combineGeometry.js +0 -53
- package/template/public/Cesium1.119/Workers/createBoxGeometry.js +0 -45
- package/template/public/Cesium1.119/Workers/createBoxOutlineGeometry.js +0 -189
- package/template/public/Cesium1.119/Workers/createCircleGeometry.js +0 -148
- package/template/public/Cesium1.119/Workers/createCircleOutlineGeometry.js +0 -105
- package/template/public/Cesium1.119/Workers/createCoplanarPolygonGeometry.js +0 -293
- package/template/public/Cesium1.119/Workers/createCoplanarPolygonOutlineGeometry.js +0 -143
- package/template/public/Cesium1.119/Workers/createCorridorGeometry.js +0 -830
- package/template/public/Cesium1.119/Workers/createCorridorOutlineGeometry.js +0 -417
- package/template/public/Cesium1.119/Workers/createCylinderGeometry.js +0 -47
- package/template/public/Cesium1.119/Workers/createCylinderOutlineGeometry.js +0 -170
- package/template/public/Cesium1.119/Workers/createEllipseGeometry.js +0 -58
- package/template/public/Cesium1.119/Workers/createEllipseOutlineGeometry.js +0 -51
- package/template/public/Cesium1.119/Workers/createEllipsoidGeometry.js +0 -46
- package/template/public/Cesium1.119/Workers/createEllipsoidOutlineGeometry.js +0 -45
- package/template/public/Cesium1.119/Workers/createFrustumGeometry.js +0 -45
- package/template/public/Cesium1.119/Workers/createFrustumOutlineGeometry.js +0 -164
- package/template/public/Cesium1.119/Workers/createGeometry.js +0 -159
- package/template/public/Cesium1.119/Workers/createGroundPolylineGeometry.js +0 -911
- package/template/public/Cesium1.119/Workers/createPlaneGeometry.js +0 -185
- package/template/public/Cesium1.119/Workers/createPlaneOutlineGeometry.js +0 -93
- package/template/public/Cesium1.119/Workers/createPolygonGeometry.js +0 -884
- package/template/public/Cesium1.119/Workers/createPolygonOutlineGeometry.js +0 -359
- package/template/public/Cesium1.119/Workers/createPolylineGeometry.js +0 -349
- package/template/public/Cesium1.119/Workers/createPolylineVolumeGeometry.js +0 -262
- package/template/public/Cesium1.119/Workers/createPolylineVolumeOutlineGeometry.js +0 -177
- package/template/public/Cesium1.119/Workers/createRectangleGeometry.js +0 -787
- package/template/public/Cesium1.119/Workers/createRectangleOutlineGeometry.js +0 -299
- package/template/public/Cesium1.119/Workers/createSimplePolylineGeometry.js +0 -294
- package/template/public/Cesium1.119/Workers/createSphereGeometry.js +0 -84
- package/template/public/Cesium1.119/Workers/createSphereOutlineGeometry.js +0 -83
- package/template/public/Cesium1.119/Workers/createTaskProcessorWorker.js +0 -28
- package/template/public/Cesium1.119/Workers/createVectorTileClampedPolylines.js +0 -289
- package/template/public/Cesium1.119/Workers/createVectorTileGeometries.js +0 -258
- package/template/public/Cesium1.119/Workers/createVectorTilePoints.js +0 -79
- package/template/public/Cesium1.119/Workers/createVectorTilePolygons.js +0 -275
- package/template/public/Cesium1.119/Workers/createVectorTilePolylines.js +0 -176
- package/template/public/Cesium1.119/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +0 -375
- package/template/public/Cesium1.119/Workers/createVerticesFromHeightmap.js +0 -1772
- package/template/public/Cesium1.119/Workers/createVerticesFromQuantizedTerrainMesh.js +0 -425
- package/template/public/Cesium1.119/Workers/createWallGeometry.js +0 -320
- package/template/public/Cesium1.119/Workers/createWallOutlineGeometry.js +0 -229
- package/template/public/Cesium1.119/Workers/decodeDraco.js +0 -227
- package/template/public/Cesium1.119/Workers/decodeGoogleEarthEnterprisePacket.js +0 -1836
- package/template/public/Cesium1.119/Workers/decodeI3S.js +0 -924
- package/template/public/Cesium1.119/Workers/transcodeKTX2.js +0 -3180
- package/template/public/Cesium1.119/Workers/transferTypedArrayTest.js +0 -34
- package/template/public/Cesium1.119/Workers/upsampleQuantizedTerrainMesh.js +0 -534
- package/template/public/Cesium1.119/index.cjs +0 -185632
- package/template/public/Cesium1.119/index.js +0 -182874
- package/template/src/views/Test/index.vue +0 -56
- package/template/tests/unit/example.test.ts +0 -7
package/README.md
CHANGED
|
@@ -1,29 +1,47 @@
|
|
|
1
1
|
# create-swdg-frontend
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
3
|
+
从 SWDG 模板生成新项目。npm 包名 **`create-swdg-frontend`**,对应命令:
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
6
|
pnpm create swdg-frontend my-app
|
|
9
|
-
#
|
|
7
|
+
# 或
|
|
10
8
|
pnpm dlx create-swdg-frontend my-app
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
> `pnpm create swdg` 会去找包 `create-swdg`(与本包无关),请使用上面的 `swdg-frontend`。
|
|
12
|
+
|
|
13
|
+
### 常用参数
|
|
14
|
+
|
|
15
|
+
| 参数 | 说明 |
|
|
16
|
+
|------|------|
|
|
17
|
+
| `--no-gis` | 不引入 Cesium(默认交互也为否) |
|
|
18
|
+
| `--gis` | 启用 GIS 依赖与示例 |
|
|
19
|
+
| `--no-install` | 跳过安装 |
|
|
20
|
+
| `--verify` | 安装后执行 `typecheck` |
|
|
21
|
+
| `--git` | `git init` |
|
|
22
|
+
|
|
23
|
+
生成项目包含 `.swdg/manifest.json` 记录创建选项。
|
|
24
|
+
|
|
25
|
+
## 维护(模板负责人)
|
|
14
26
|
|
|
15
27
|
```bash
|
|
28
|
+
# 从 monorepo 根目录同步
|
|
16
29
|
pnpm run sync-template
|
|
30
|
+
|
|
31
|
+
# 发布前校验 template 能 typecheck
|
|
32
|
+
pnpm run validate-template
|
|
17
33
|
```
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
`prepublishOnly` 会自动 sync + validate。
|
|
20
36
|
|
|
21
|
-
|
|
22
|
-
TEMPLATE_REPO=http://10.20.124.70/bim/frontend-framework.git TEMPLATE_BRANCH=main pnpm run sync-template
|
|
23
|
-
```
|
|
37
|
+
环境变量:
|
|
24
38
|
|
|
25
|
-
|
|
39
|
+
- `TEMPLATE_DIR` — 本地模板路径
|
|
40
|
+
- `TEMPLATE_REPO` / `TEMPLATE_BRANCH` — 远程 git 同步
|
|
26
41
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
42
|
+
## 包内容
|
|
43
|
+
|
|
44
|
+
- `bin/` — 入口
|
|
45
|
+
- `lib/` — CLI 模块(prompts、gis、manifest、scaffold)
|
|
46
|
+
- `stubs/` — 无 GIS 时的 vite/tsconfig/env 替身
|
|
47
|
+
- `template/` — 同步后的完整项目
|
package/bin/index.js
CHANGED
|
@@ -1,248 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { spawn } from 'node:child_process';
|
|
6
|
-
import readline from 'node:readline/promises';
|
|
2
|
+
import { run } from '../lib/cli.js';
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let pm = 'pnpm';
|
|
11
|
-
let targetDir;
|
|
12
|
-
let shouldInstall;
|
|
13
|
-
let shouldInitGit;
|
|
14
|
-
let shouldIncludeGis;
|
|
15
|
-
const flags = new Set();
|
|
16
|
-
|
|
17
|
-
for (let i = 0; i < argv.length; i += 1) {
|
|
18
|
-
const arg = argv[i];
|
|
19
|
-
if (arg === '--pm') {
|
|
20
|
-
pm = argv[i + 1] ?? pm;
|
|
21
|
-
i += 1;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (arg.startsWith('--pm=')) {
|
|
25
|
-
pm = arg.slice('--pm='.length) || pm;
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (arg === '--install') {
|
|
29
|
-
shouldInstall = true;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (arg === '--no-install') {
|
|
33
|
-
shouldInstall = false;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (arg === '--git') {
|
|
37
|
-
shouldInitGit = true;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (arg === '--no-git') {
|
|
41
|
-
shouldInitGit = false;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (arg === '--gis') {
|
|
45
|
-
shouldIncludeGis = true;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (arg === '--no-gis') {
|
|
49
|
-
shouldIncludeGis = false;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (arg.startsWith('-')) {
|
|
53
|
-
flags.add(arg);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (!targetDir) targetDir = arg;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (flags.has('--help') || flags.has('-h')) {
|
|
60
|
-
console.log(
|
|
61
|
-
`\nUsage: pnpm create swdg [project-name] [--install|--no-install] [--git|--no-git] [--gis|--no-gis] [--pm pnpm|npm|yarn]\n`
|
|
62
|
-
);
|
|
63
|
-
process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
67
|
-
const __dirname = path.dirname(__filename);
|
|
68
|
-
const templateDir = path.resolve(__dirname, '../template');
|
|
69
|
-
let destDir;
|
|
70
|
-
|
|
71
|
-
function isValidPackageName(name) {
|
|
72
|
-
if (!name) return false;
|
|
73
|
-
if (name.startsWith('@')) return false;
|
|
74
|
-
if (name.length > 214) return false;
|
|
75
|
-
return /^[a-z0-9][a-z0-9._-]*$/.test(name);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function resolveTargetDir() {
|
|
79
|
-
if (targetDir) {
|
|
80
|
-
if (!isValidPackageName(targetDir)) {
|
|
81
|
-
console.error(
|
|
82
|
-
'Invalid project name. Use lowercase letters, numbers, dots, dashes or underscores.'
|
|
83
|
-
);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
return targetDir;
|
|
87
|
-
}
|
|
88
|
-
const rl = readline.createInterface({
|
|
89
|
-
input: process.stdin,
|
|
90
|
-
output: process.stdout,
|
|
91
|
-
});
|
|
92
|
-
let name = '';
|
|
93
|
-
while (!isValidPackageName(name)) {
|
|
94
|
-
const answer = await rl.question('Project name (my-app): ');
|
|
95
|
-
name = answer.trim() || 'my-app';
|
|
96
|
-
if (!isValidPackageName(name)) {
|
|
97
|
-
console.log(
|
|
98
|
-
'Invalid project name. Use lowercase letters, numbers, dots, dashes or underscores.'
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
rl.close();
|
|
103
|
-
return name;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function resolveGisChoice() {
|
|
107
|
-
if (shouldIncludeGis === true) return true;
|
|
108
|
-
if (shouldIncludeGis === false) return false;
|
|
109
|
-
const rl = readline.createInterface({
|
|
110
|
-
input: process.stdin,
|
|
111
|
-
output: process.stdout,
|
|
112
|
-
});
|
|
113
|
-
const answer = await rl.question('Include GIS (Cesium) assets? (Y/n): ');
|
|
114
|
-
rl.close();
|
|
115
|
-
if (!answer.trim()) return true;
|
|
116
|
-
return /^y(es)?$/i.test(answer.trim());
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async function pathExists(p) {
|
|
120
|
-
try {
|
|
121
|
-
await fs.access(p);
|
|
122
|
-
return true;
|
|
123
|
-
} catch {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
async function isDirEmpty(p) {
|
|
129
|
-
try {
|
|
130
|
-
const entries = await fs.readdir(p);
|
|
131
|
-
return entries.length === 0;
|
|
132
|
-
} catch {
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async function copyTemplate() {
|
|
138
|
-
if (await pathExists(destDir)) {
|
|
139
|
-
const empty = await isDirEmpty(destDir);
|
|
140
|
-
if (!empty) {
|
|
141
|
-
const rl = readline.createInterface({
|
|
142
|
-
input: process.stdin,
|
|
143
|
-
output: process.stdout,
|
|
144
|
-
});
|
|
145
|
-
const answer = await rl.question(
|
|
146
|
-
`Target directory is not empty. Remove and continue? (y/N): `
|
|
147
|
-
);
|
|
148
|
-
rl.close();
|
|
149
|
-
if (!/^y(es)?$/i.test(answer.trim())) {
|
|
150
|
-
console.error('Aborted.');
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
await fs.rm(destDir, { recursive: true, force: true });
|
|
154
|
-
await fs.mkdir(destDir, { recursive: true });
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
await fs.mkdir(destDir, { recursive: true });
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
await fs.cp(templateDir, destDir, { recursive: true });
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
async function updatePackageName() {
|
|
164
|
-
const pkgPath = path.join(destDir, 'package.json');
|
|
165
|
-
const raw = await fs.readFile(pkgPath, 'utf8');
|
|
166
|
-
const pkg = JSON.parse(raw);
|
|
167
|
-
pkg.name = path.basename(destDir);
|
|
168
|
-
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async function updateIndexTitle() {
|
|
172
|
-
const indexPath = path.join(destDir, 'index.html');
|
|
173
|
-
try {
|
|
174
|
-
const html = await fs.readFile(indexPath, 'utf8');
|
|
175
|
-
const title = path.basename(destDir);
|
|
176
|
-
const next = html.replace(
|
|
177
|
-
/<title>.*?<\/title>/i,
|
|
178
|
-
`<title>${title}</title>`
|
|
179
|
-
);
|
|
180
|
-
await fs.writeFile(indexPath, next, 'utf8');
|
|
181
|
-
} catch {
|
|
182
|
-
// Ignore if index.html does not exist
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async function removeGisAssets() {
|
|
187
|
-
const gisDir = path.join(destDir, 'public', 'Cesium1.119');
|
|
188
|
-
await fs.rm(gisDir, { recursive: true, force: true });
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
async function runInstall() {
|
|
192
|
-
const cmd = pm || 'pnpm';
|
|
193
|
-
const child = spawn(cmd, ['install'], {
|
|
194
|
-
cwd: destDir,
|
|
195
|
-
stdio: 'inherit',
|
|
196
|
-
});
|
|
197
|
-
await new Promise((resolve, reject) => {
|
|
198
|
-
child.on('exit', (code) => {
|
|
199
|
-
if (code === 0) resolve();
|
|
200
|
-
else reject(new Error(`${cmd} install failed with code ${code}`));
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
async function initGit() {
|
|
206
|
-
await new Promise((resolve, reject) => {
|
|
207
|
-
const child = spawn('git', ['init'], {
|
|
208
|
-
cwd: destDir,
|
|
209
|
-
stdio: 'inherit',
|
|
210
|
-
});
|
|
211
|
-
child.on('exit', (code) => {
|
|
212
|
-
if (code === 0) resolve();
|
|
213
|
-
else reject(new Error(`git init failed with code ${code}`));
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
try {
|
|
219
|
-
targetDir = await resolveTargetDir();
|
|
220
|
-
destDir = path.resolve(process.cwd(), targetDir);
|
|
221
|
-
await copyTemplate();
|
|
222
|
-
await updatePackageName();
|
|
223
|
-
await updateIndexTitle();
|
|
224
|
-
|
|
225
|
-
const includeGis = await resolveGisChoice();
|
|
226
|
-
if (!includeGis) {
|
|
227
|
-
await removeGisAssets();
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (shouldInitGit === true) {
|
|
231
|
-
await initGit();
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (
|
|
235
|
-
shouldInstall === true ||
|
|
236
|
-
(shouldInstall !== false && flags.has('--install'))
|
|
237
|
-
) {
|
|
238
|
-
await runInstall();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
console.log(`\nProject created at ${destDir}`);
|
|
242
|
-
console.log(
|
|
243
|
-
`\nNext steps:\n cd ${targetDir}\n ${pm} install\n ${pm} run dev\n`
|
|
244
|
-
);
|
|
245
|
-
} catch (err) {
|
|
4
|
+
run(process.argv.slice(2)).catch((err) => {
|
|
246
5
|
console.error(err?.message ?? err);
|
|
247
6
|
process.exit(1);
|
|
248
|
-
}
|
|
7
|
+
});
|
package/lib/argv.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** @param {string[]} argv process.argv slice after node & script */
|
|
2
|
+
export function parseArgv(argv) {
|
|
3
|
+
const flags = new Set();
|
|
4
|
+
let pm = 'pnpm';
|
|
5
|
+
let targetDir;
|
|
6
|
+
let shouldInstall;
|
|
7
|
+
let shouldInitGit;
|
|
8
|
+
let shouldIncludeGis;
|
|
9
|
+
let shouldVerify;
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
12
|
+
const arg = argv[i];
|
|
13
|
+
if (arg === '--pm') {
|
|
14
|
+
pm = argv[i + 1] ?? pm;
|
|
15
|
+
i += 1;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (arg.startsWith('--pm=')) {
|
|
19
|
+
pm = arg.slice('--pm='.length) || pm;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (arg === '--install') shouldInstall = true;
|
|
23
|
+
else if (arg === '--no-install') shouldInstall = false;
|
|
24
|
+
else if (arg === '--git') shouldInitGit = true;
|
|
25
|
+
else if (arg === '--no-git') shouldInitGit = false;
|
|
26
|
+
else if (arg === '--gis') shouldIncludeGis = true;
|
|
27
|
+
else if (arg === '--no-gis') shouldIncludeGis = false;
|
|
28
|
+
else if (arg === '--verify') shouldVerify = true;
|
|
29
|
+
else if (arg === '--no-verify') shouldVerify = false;
|
|
30
|
+
else if (arg.startsWith('-')) flags.add(arg);
|
|
31
|
+
else if (!targetDir) targetDir = arg;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
flags,
|
|
36
|
+
pm,
|
|
37
|
+
targetDir,
|
|
38
|
+
shouldInstall,
|
|
39
|
+
shouldInitGit,
|
|
40
|
+
shouldIncludeGis,
|
|
41
|
+
shouldVerify,
|
|
42
|
+
};
|
|
43
|
+
}
|
package/lib/cli.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import readline from 'node:readline/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { FEATURES } from './constants.js';
|
|
4
|
+
import { promptLine, resolveProjectName } from './prompts.js';
|
|
5
|
+
import {
|
|
6
|
+
applyFeatures,
|
|
7
|
+
copyTemplate,
|
|
8
|
+
finalizeProject,
|
|
9
|
+
initGit,
|
|
10
|
+
runInstall,
|
|
11
|
+
updateIndexTitle,
|
|
12
|
+
updatePackageName,
|
|
13
|
+
verifyProject,
|
|
14
|
+
} from './scaffold.js';
|
|
15
|
+
import { parseArgv } from './argv.js';
|
|
16
|
+
|
|
17
|
+
function printHelp() {
|
|
18
|
+
console.log(`
|
|
19
|
+
Usage: pnpm create swdg [project-name] [options]
|
|
20
|
+
|
|
21
|
+
大厂式脚手架:薄 CLI + 厚模板 + 可选特性(feature flags)
|
|
22
|
+
|
|
23
|
+
交互(未传 flag 时):
|
|
24
|
+
- 项目名称
|
|
25
|
+
- 是否启用 GIS(Cesium)— 默认否,按需开启
|
|
26
|
+
- 是否现在安装依赖 — 默认是
|
|
27
|
+
- 是否初始化 Git — 默认否
|
|
28
|
+
- 是否运行 typecheck 校验 — 默认是
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--gis / --no-gis 三维地图能力(npm + 示例页)
|
|
32
|
+
--install / --no-install 安装依赖
|
|
33
|
+
--git / --no-git git init
|
|
34
|
+
--verify / --no-verify 创建后执行 pnpm typecheck
|
|
35
|
+
--pm pnpm|npm|yarn
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function confirmOverwrite(_destDir) {
|
|
40
|
+
const rl = readline.createInterface({
|
|
41
|
+
input: process.stdin,
|
|
42
|
+
output: process.stdout,
|
|
43
|
+
});
|
|
44
|
+
const answer = await rl.question(
|
|
45
|
+
'Target directory is not empty. Remove and continue? (y/N): '
|
|
46
|
+
);
|
|
47
|
+
rl.close();
|
|
48
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function resolveGisChoice(shouldIncludeGis) {
|
|
52
|
+
if (shouldIncludeGis === true) return true;
|
|
53
|
+
if (shouldIncludeGis === false) return false;
|
|
54
|
+
return promptLine(
|
|
55
|
+
`是否启用 ${FEATURES.gis.label}?[y/N]: `,
|
|
56
|
+
FEATURES.gis.defaultEnabled
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function run(argv) {
|
|
61
|
+
const parsed = parseArgv(argv);
|
|
62
|
+
if (parsed.flags.has('--help') || parsed.flags.has('-h')) {
|
|
63
|
+
printHelp();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const projectName = await resolveProjectName(parsed.targetDir);
|
|
68
|
+
const includeGis = await resolveGisChoice(parsed.shouldIncludeGis);
|
|
69
|
+
const installDeps =
|
|
70
|
+
parsed.shouldInstall === true
|
|
71
|
+
? true
|
|
72
|
+
: parsed.shouldInstall === false
|
|
73
|
+
? false
|
|
74
|
+
: await promptLine('是否现在安装依赖?(Y/n): ', true);
|
|
75
|
+
const initGitRepo =
|
|
76
|
+
parsed.shouldInitGit === true
|
|
77
|
+
? true
|
|
78
|
+
: parsed.shouldInitGit === false
|
|
79
|
+
? false
|
|
80
|
+
: await promptLine('是否初始化 Git 仓库?(y/N): ', false);
|
|
81
|
+
const runVerify =
|
|
82
|
+
parsed.shouldVerify === true
|
|
83
|
+
? true
|
|
84
|
+
: parsed.shouldVerify === false
|
|
85
|
+
? false
|
|
86
|
+
: await promptLine('创建后运行 typecheck 校验?(Y/n): ', true);
|
|
87
|
+
|
|
88
|
+
const destDir = path.resolve(process.cwd(), projectName);
|
|
89
|
+
|
|
90
|
+
console.log('\n── SWDG 创建摘要 ──');
|
|
91
|
+
console.log(` 项目: ${projectName}`);
|
|
92
|
+
console.log(` GIS: ${includeGis ? '启用' : '关闭'}`);
|
|
93
|
+
console.log(` 安装: ${installDeps ? '是' : '否'}`);
|
|
94
|
+
console.log(` Git: ${initGitRepo ? '是' : '否'}`);
|
|
95
|
+
console.log(` 校验: ${runVerify ? 'typecheck' : '跳过'}`);
|
|
96
|
+
console.log('──────────────────\n');
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
await copyTemplate(destDir);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (err.message === 'TARGET_NOT_EMPTY') {
|
|
102
|
+
if (!(await confirmOverwrite(destDir))) {
|
|
103
|
+
console.error('Aborted.');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
await copyTemplate(destDir, { forceEmpty: true });
|
|
107
|
+
} else {
|
|
108
|
+
throw err;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
await updatePackageName(destDir, projectName);
|
|
113
|
+
await updateIndexTitle(destDir, projectName);
|
|
114
|
+
await applyFeatures(destDir, { gis: includeGis });
|
|
115
|
+
await finalizeProject(destDir, { gis: includeGis, pm: parsed.pm });
|
|
116
|
+
|
|
117
|
+
if (initGitRepo) await initGit(destDir);
|
|
118
|
+
if (installDeps) {
|
|
119
|
+
console.log(`\nInstalling dependencies (${parsed.pm})…\n`);
|
|
120
|
+
await runInstall(destDir, parsed.pm);
|
|
121
|
+
}
|
|
122
|
+
if (runVerify && installDeps) {
|
|
123
|
+
console.log('\nRunning post-scaffold verification (typecheck)…\n');
|
|
124
|
+
await verifyProject(destDir, parsed.pm);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
console.log(`\n✓ Project ready: ${destDir}`);
|
|
128
|
+
console.log(` Manifest: .swdg/manifest.json`);
|
|
129
|
+
console.log(` Onboarding: docs/ONBOARDING.md`);
|
|
130
|
+
if (!installDeps) {
|
|
131
|
+
console.log(
|
|
132
|
+
`\n cd ${projectName} && ${parsed.pm} install && ${parsed.pm} run dev`
|
|
133
|
+
);
|
|
134
|
+
} else {
|
|
135
|
+
console.log(`\n cd ${projectName} && ${parsed.pm} run dev`);
|
|
136
|
+
}
|
|
137
|
+
if (includeGis) {
|
|
138
|
+
console.log(' GIS demo: /#/examples/cesium');
|
|
139
|
+
}
|
|
140
|
+
console.log(' Examples (dev): /#/examples/test');
|
|
141
|
+
}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
|
|
6
|
+
export const PACKAGE_ROOT = path.resolve(__dirname, '..');
|
|
7
|
+
export const TEMPLATE_DIR = path.join(PACKAGE_ROOT, 'template');
|
|
8
|
+
export const STUBS_DIR = path.join(PACKAGE_ROOT, 'stubs');
|
|
9
|
+
export const SCAFFOLD_VERSION = '0.2.1';
|
|
10
|
+
|
|
11
|
+
/** 可选特性:重型依赖默认关闭,创建时 opt-in */
|
|
12
|
+
export const FEATURES = {
|
|
13
|
+
gis: {
|
|
14
|
+
id: 'gis',
|
|
15
|
+
label: 'GIS(Cesium 三维地图)',
|
|
16
|
+
defaultEnabled: false,
|
|
17
|
+
paths: [
|
|
18
|
+
'scripts/vite-plugin-cesium-dev.ts',
|
|
19
|
+
'src/utils/cesium',
|
|
20
|
+
'src/components/CesiumViewer',
|
|
21
|
+
'src/views/examples/cesium',
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
};
|
package/lib/gis.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { FEATURES, STUBS_DIR } from './constants.js';
|
|
4
|
+
|
|
5
|
+
const { paths: GIS_PATHS } = FEATURES.gis;
|
|
6
|
+
|
|
7
|
+
async function removePathIfExists(destDir, relativePath) {
|
|
8
|
+
await fs.rm(path.join(destDir, relativePath), {
|
|
9
|
+
recursive: true,
|
|
10
|
+
force: true,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function patchPackageWithoutGis(destDir) {
|
|
15
|
+
const pkgPath = path.join(destDir, 'package.json');
|
|
16
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'));
|
|
17
|
+
if (pkg.dependencies) delete pkg.dependencies.cesium;
|
|
18
|
+
if (pkg.devDependencies)
|
|
19
|
+
delete pkg.devDependencies['vite-plugin-static-copy'];
|
|
20
|
+
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function patchReadmeWithoutGis(destDir) {
|
|
24
|
+
const readmePath = path.join(destDir, 'README.md');
|
|
25
|
+
try {
|
|
26
|
+
let content = await fs.readFile(readmePath, 'utf8');
|
|
27
|
+
content = content.replace(/\n## Cesium[\s\S]*?(?=\n## )/, '\n');
|
|
28
|
+
await fs.writeFile(readmePath, content, 'utf8');
|
|
29
|
+
} catch {
|
|
30
|
+
// ignore
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function applyNoGisStubs(destDir) {
|
|
35
|
+
const pairs = [
|
|
36
|
+
['vite.config.ts', 'vite.config.ts'],
|
|
37
|
+
['tsconfig.node.json', 'tsconfig.node.json'],
|
|
38
|
+
['types-env.d.ts', path.join('types', 'env.d.ts')],
|
|
39
|
+
];
|
|
40
|
+
for (const [stubName, destRel] of pairs) {
|
|
41
|
+
await fs.copyFile(
|
|
42
|
+
path.join(STUBS_DIR, stubName),
|
|
43
|
+
path.join(destDir, destRel)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function upsertEnvFeature(destDir, enabled) {
|
|
49
|
+
const envExample = path.join(destDir, '.env.example');
|
|
50
|
+
let content;
|
|
51
|
+
try {
|
|
52
|
+
content = await fs.readFile(envExample, 'utf8');
|
|
53
|
+
} catch {
|
|
54
|
+
content = 'VITE_DEMO_PROXY_TARGET=http://127.0.0.1:8888\n\n';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const line = 'VITE_FEATURE_GIS=true';
|
|
58
|
+
if (enabled) {
|
|
59
|
+
if (!content.includes('VITE_FEATURE_GIS')) {
|
|
60
|
+
content += `\n# GIS (Cesium)\n${line}\n`;
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
content = content
|
|
64
|
+
.replace(/\n?# GIS \(Cesium\)[\s\S]*?VITE_FEATURE_GIS=true\n?/g, '\n')
|
|
65
|
+
.replace(/\n?VITE_FEATURE_GIS=true\n?/g, '\n');
|
|
66
|
+
}
|
|
67
|
+
await fs.writeFile(envExample, content, 'utf8');
|
|
68
|
+
|
|
69
|
+
const envPath = path.join(destDir, '.env');
|
|
70
|
+
if (enabled) {
|
|
71
|
+
const envBody = `VITE_DEMO_PROXY_TARGET=http://127.0.0.1:8888\n${line}\n`;
|
|
72
|
+
try {
|
|
73
|
+
await fs.access(envPath);
|
|
74
|
+
} catch {
|
|
75
|
+
await fs.writeFile(envPath, envBody, 'utf8');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function applyGisIntegration(destDir) {
|
|
81
|
+
await upsertEnvFeature(destDir, true);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function removeGisIntegration(destDir) {
|
|
85
|
+
for (const relativePath of GIS_PATHS) {
|
|
86
|
+
await removePathIfExists(destDir, relativePath);
|
|
87
|
+
}
|
|
88
|
+
await patchPackageWithoutGis(destDir);
|
|
89
|
+
await patchReadmeWithoutGis(destDir);
|
|
90
|
+
await applyNoGisStubs(destDir);
|
|
91
|
+
await upsertEnvFeature(destDir, false);
|
|
92
|
+
}
|
package/lib/manifest.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { SCAFFOLD_VERSION } from './constants.js';
|
|
4
|
+
|
|
5
|
+
export async function writeProjectManifest(destDir, options) {
|
|
6
|
+
const manifestDir = path.join(destDir, '.swdg');
|
|
7
|
+
await fs.mkdir(manifestDir, { recursive: true });
|
|
8
|
+
|
|
9
|
+
const manifest = {
|
|
10
|
+
schemaVersion: 1,
|
|
11
|
+
generator: 'create-swdg-frontend',
|
|
12
|
+
generatorVersion: SCAFFOLD_VERSION,
|
|
13
|
+
createdAt: new Date().toISOString(),
|
|
14
|
+
features: options.features,
|
|
15
|
+
packageManager: options.packageManager,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
await fs.writeFile(
|
|
19
|
+
path.join(manifestDir, 'manifest.json'),
|
|
20
|
+
JSON.stringify(manifest, null, 2) + '\n',
|
|
21
|
+
'utf8'
|
|
22
|
+
);
|
|
23
|
+
}
|
package/lib/prompts.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import readline from 'node:readline/promises';
|
|
2
|
+
|
|
3
|
+
export function parseYesNo(answer, defaultYes = true) {
|
|
4
|
+
const trimmed = answer.trim();
|
|
5
|
+
if (!trimmed) return defaultYes;
|
|
6
|
+
if (/^y(es)?$/i.test(trimmed)) return true;
|
|
7
|
+
if (/^n(o)?$/i.test(trimmed)) return false;
|
|
8
|
+
return defaultYes;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function createInterface() {
|
|
12
|
+
return readline.createInterface({
|
|
13
|
+
input: process.stdin,
|
|
14
|
+
output: process.stdout,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function promptLine(question, defaultYes = true) {
|
|
19
|
+
const rl = createInterface();
|
|
20
|
+
const answer = await rl.question(question);
|
|
21
|
+
rl.close();
|
|
22
|
+
return parseYesNo(answer, defaultYes);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isValidPackageName(name) {
|
|
26
|
+
if (!name) return false;
|
|
27
|
+
if (name.startsWith('@')) return false;
|
|
28
|
+
if (name.length > 214) return false;
|
|
29
|
+
return /^[a-z0-9][a-z0-9._-]*$/.test(name);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function resolveProjectName(argvName) {
|
|
33
|
+
if (argvName) {
|
|
34
|
+
if (!isValidPackageName(argvName)) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'Invalid project name. Use lowercase letters, numbers, dots, dashes or underscores.'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return argvName;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const rl = createInterface();
|
|
43
|
+
let name = '';
|
|
44
|
+
while (!isValidPackageName(name)) {
|
|
45
|
+
const answer = await rl.question('Project name (my-app): ');
|
|
46
|
+
name = answer.trim() || 'my-app';
|
|
47
|
+
if (!isValidPackageName(name)) {
|
|
48
|
+
console.log(
|
|
49
|
+
'Invalid project name. Use lowercase letters, numbers, dots, dashes or underscores.'
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
rl.close();
|
|
54
|
+
return name;
|
|
55
|
+
}
|