@weapp-core/init 4.1.0 → 5.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/dist/index.cjs +110 -201
- package/dist/index.d.cts +1 -12
- package/dist/index.d.ts +1 -12
- package/dist/index.js +110 -193
- package/package.json +3 -10
- package/templates/default/.editorconfig +0 -9
- package/templates/default/.vscode/settings.json +0 -5
- package/templates/default/README.md +0 -28
- package/templates/default/auto-import-components.json +0 -3
- package/templates/default/gitignore +0 -35
- package/templates/default/package.json +0 -31
- package/templates/default/project.config.json +0 -42
- package/templates/default/project.private.config.json +0 -8
- package/templates/default/public/logo.png +0 -0
- package/templates/default/src/app.json +0 -10
- package/templates/default/src/app.scss +0 -0
- package/templates/default/src/app.ts +0 -6
- package/templates/default/src/components/HelloWorld/HelloWorld.json +0 -6
- package/templates/default/src/components/HelloWorld/HelloWorld.scss +0 -47
- package/templates/default/src/components/HelloWorld/HelloWorld.ts +0 -61
- package/templates/default/src/components/HelloWorld/HelloWorld.wxml +0 -16
- package/templates/default/src/pages/index/index.json +0 -7
- package/templates/default/src/pages/index/index.scss +0 -0
- package/templates/default/src/pages/index/index.ts +0 -24
- package/templates/default/src/pages/index/index.wxml +0 -14
- package/templates/default/src/sitemap.json +0 -10
- package/templates/default/src/theme.json +0 -5
- package/templates/default/src/utils/util.ts +0 -3
- package/templates/default/src/vite-env.d.ts +0 -1
- package/templates/default/tsconfig.app.json +0 -60
- package/templates/default/tsconfig.json +0 -11
- package/templates/default/tsconfig.node.json +0 -33
- package/templates/default/vite.config.ts +0 -39
- package/templates/tailwindcss/.editorconfig +0 -9
- package/templates/tailwindcss/.vscode/settings.json +0 -5
- package/templates/tailwindcss/README.md +0 -28
- package/templates/tailwindcss/auto-import-components.json +0 -3
- package/templates/tailwindcss/gitignore +0 -35
- package/templates/tailwindcss/package.json +0 -38
- package/templates/tailwindcss/postcss.config.js +0 -6
- package/templates/tailwindcss/project.config.json +0 -43
- package/templates/tailwindcss/project.private.config.json +0 -8
- package/templates/tailwindcss/public/icon0.png +0 -0
- package/templates/tailwindcss/public/icon0s.png +0 -0
- package/templates/tailwindcss/public/icon1.png +0 -0
- package/templates/tailwindcss/public/icon1s.png +0 -0
- package/templates/tailwindcss/public/logo.png +0 -0
- package/templates/tailwindcss/src/app.json +0 -31
- package/templates/tailwindcss/src/app.scss +0 -3
- package/templates/tailwindcss/src/app.ts +0 -6
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.json +0 -7
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.scss +0 -1
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +0 -61
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.wxml +0 -16
- package/templates/tailwindcss/src/pages/index/index.json +0 -7
- package/templates/tailwindcss/src/pages/index/index.scss +0 -0
- package/templates/tailwindcss/src/pages/index/index.ts +0 -48
- package/templates/tailwindcss/src/pages/index/index.wxml +0 -24
- package/templates/tailwindcss/src/pages/profile/index.json +0 -7
- package/templates/tailwindcss/src/pages/profile/index.scss +0 -0
- package/templates/tailwindcss/src/pages/profile/index.ts +0 -19
- package/templates/tailwindcss/src/pages/profile/index.wxml +0 -11
- package/templates/tailwindcss/src/sitemap.json +0 -10
- package/templates/tailwindcss/src/theme.json +0 -5
- package/templates/tailwindcss/src/utils/util.ts +0 -3
- package/templates/tailwindcss/src/vite-env.d.ts +0 -1
- package/templates/tailwindcss/tailwind.config.ts +0 -22
- package/templates/tailwindcss/tsconfig.app.json +0 -60
- package/templates/tailwindcss/tsconfig.json +0 -11
- package/templates/tailwindcss/tsconfig.node.json +0 -33
- package/templates/tailwindcss/vite.config.ts +0 -37
- package/templates/tdesign/.editorconfig +0 -9
- package/templates/tdesign/.vscode/settings.json +0 -5
- package/templates/tdesign/README.md +0 -28
- package/templates/tdesign/gitignore +0 -35
- package/templates/tdesign/package.json +0 -41
- package/templates/tdesign/postcss.config.js +0 -6
- package/templates/tdesign/project.config.json +0 -45
- package/templates/tdesign/project.private.config.json +0 -8
- package/templates/tdesign/public/logo.png +0 -0
- package/templates/tdesign/src/app.json +0 -10
- package/templates/tdesign/src/app.scss +0 -3
- package/templates/tdesign/src/app.ts +0 -6
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.json +0 -8
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.scss +0 -1
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +0 -64
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.wxml +0 -17
- package/templates/tdesign/src/pages/index/index.json +0 -7
- package/templates/tdesign/src/pages/index/index.scss +0 -0
- package/templates/tdesign/src/pages/index/index.ts +0 -97
- package/templates/tdesign/src/pages/index/index.wxml +0 -24
- package/templates/tdesign/src/sitemap.json +0 -10
- package/templates/tdesign/src/theme.json +0 -5
- package/templates/tdesign/src/utils/util.ts +0 -3
- package/templates/tdesign/src/vite-env.d.ts +0 -1
- package/templates/tdesign/tailwind.config.ts +0 -22
- package/templates/tdesign/tsconfig.app.json +0 -63
- package/templates/tdesign/tsconfig.json +0 -11
- package/templates/tdesign/tsconfig.node.json +0 -33
- package/templates/tdesign/vite.config.ts +0 -41
- package/templates/vant/.editorconfig +0 -9
- package/templates/vant/.vscode/settings.json +0 -5
- package/templates/vant/README.md +0 -28
- package/templates/vant/gitignore +0 -35
- package/templates/vant/package.json +0 -41
- package/templates/vant/postcss.config.js +0 -6
- package/templates/vant/project.config.json +0 -42
- package/templates/vant/project.private.config.json +0 -8
- package/templates/vant/public/logo.png +0 -0
- package/templates/vant/src/app.json +0 -10
- package/templates/vant/src/app.scss +0 -3
- package/templates/vant/src/app.ts +0 -6
- package/templates/vant/src/components/HelloWorld/HelloWorld.json +0 -9
- package/templates/vant/src/components/HelloWorld/HelloWorld.scss +0 -1
- package/templates/vant/src/components/HelloWorld/HelloWorld.ts +0 -61
- package/templates/vant/src/components/HelloWorld/HelloWorld.wxml +0 -19
- package/templates/vant/src/pages/index/index.json +0 -7
- package/templates/vant/src/pages/index/index.scss +0 -0
- package/templates/vant/src/pages/index/index.ts +0 -57
- package/templates/vant/src/pages/index/index.wxml +0 -28
- package/templates/vant/src/sitemap.json +0 -10
- package/templates/vant/src/theme.json +0 -5
- package/templates/vant/src/utils/util.ts +0 -3
- package/templates/vant/src/vite-env.d.ts +0 -1
- package/templates/vant/tailwind.config.ts +0 -22
- package/templates/vant/tsconfig.app.json +0 -63
- package/templates/vant/tsconfig.json +0 -11
- package/templates/vant/tsconfig.node.json +0 -33
- package/templates/vant/vite.config.ts +0 -41
- package/templates/wevu/.editorconfig +0 -9
- package/templates/wevu/.vscode/settings.json +0 -5
- package/templates/wevu/README.md +0 -29
- package/templates/wevu/auto-import-components.json +0 -1
- package/templates/wevu/gitignore +0 -35
- package/templates/wevu/package.json +0 -30
- package/templates/wevu/project.config.json +0 -43
- package/templates/wevu/project.private.config.json +0 -8
- package/templates/wevu/public/logo.png +0 -0
- package/templates/wevu/src/app.vue +0 -36
- package/templates/wevu/src/components/HelloWorld/index.vue +0 -45
- package/templates/wevu/src/pages/index/index.vue +0 -138
- package/templates/wevu/src/sitemap.json +0 -10
- package/templates/wevu/src/theme.json +0 -5
- package/templates/wevu/src/vite-env.d.ts +0 -1
- package/templates/wevu/tsconfig.app.json +0 -60
- package/templates/wevu/tsconfig.json +0 -11
- package/templates/wevu/tsconfig.node.json +0 -33
- package/templates/wevu/vite.config.ts +0 -8
- package/templates/wevu-tdesign/.editorconfig +0 -9
- package/templates/wevu-tdesign/.vscode/settings.json +0 -5
- package/templates/wevu-tdesign/README.md +0 -29
- package/templates/wevu-tdesign/auto-import-components.json +0 -83
- package/templates/wevu-tdesign/components.d.ts +0 -183
- package/templates/wevu-tdesign/gitignore +0 -35
- package/templates/wevu-tdesign/package.json +0 -40
- package/templates/wevu-tdesign/postcss.config.js +0 -6
- package/templates/wevu-tdesign/project.config.json +0 -43
- package/templates/wevu-tdesign/project.private.config.json +0 -8
- package/templates/wevu-tdesign/public/logo.png +0 -0
- package/templates/wevu-tdesign/src/app.vue +0 -40
- package/templates/wevu-tdesign/src/components/HelloWorld/index.vue +0 -45
- package/templates/wevu-tdesign/src/pages/index/index.vue +0 -138
- package/templates/wevu-tdesign/src/sitemap.json +0 -10
- package/templates/wevu-tdesign/src/theme.json +0 -5
- package/templates/wevu-tdesign/src/vite-env.d.ts +0 -1
- package/templates/wevu-tdesign/tailwind.config.ts +0 -22
- package/templates/wevu-tdesign/tsconfig.app.json +0 -60
- package/templates/wevu-tdesign/tsconfig.json +0 -11
- package/templates/wevu-tdesign/tsconfig.node.json +0 -33
- package/templates/wevu-tdesign/typed-components.d.ts +0 -943
- package/templates/wevu-tdesign/vite.config.ts +0 -43
package/dist/index.js
CHANGED
|
@@ -714,27 +714,12 @@ async function initTsJsonFiles(options) {
|
|
|
714
714
|
};
|
|
715
715
|
}
|
|
716
716
|
|
|
717
|
-
// src/
|
|
718
|
-
import
|
|
719
|
-
import
|
|
720
|
-
import fs2 from "fs-extra";
|
|
717
|
+
// src/packageJson.ts
|
|
718
|
+
import logger2 from "@weapp-core/logger";
|
|
719
|
+
import { defu, get, set } from "@weapp-core/shared";
|
|
721
720
|
|
|
722
721
|
// ../../packages/weapp-vite/package.json
|
|
723
|
-
var version = "6.1.
|
|
724
|
-
|
|
725
|
-
// ../../packages/wevu/package.json
|
|
726
|
-
var version2 = "1.0.1";
|
|
727
|
-
|
|
728
|
-
// src/enums.ts
|
|
729
|
-
var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
|
|
730
|
-
TemplateName2["default"] = "default";
|
|
731
|
-
TemplateName2["wevu"] = "wevu";
|
|
732
|
-
TemplateName2["tailwindcss"] = "tailwindcss";
|
|
733
|
-
TemplateName2["vant"] = "vant";
|
|
734
|
-
TemplateName2["tdesign"] = "tdesign";
|
|
735
|
-
TemplateName2["wevuTdesign"] = "wevu-tdesign";
|
|
736
|
-
return TemplateName2;
|
|
737
|
-
})(TemplateName || {});
|
|
722
|
+
var version = "6.1.4";
|
|
738
723
|
|
|
739
724
|
// src/npm.ts
|
|
740
725
|
import https from "https";
|
|
@@ -778,172 +763,7 @@ async function latestVersion(packageName, prefix = "^", fetch = getLatestVersion
|
|
|
778
763
|
}
|
|
779
764
|
}
|
|
780
765
|
|
|
781
|
-
// src/updateGitignore.ts
|
|
782
|
-
import logger2 from "@weapp-core/logger";
|
|
783
|
-
|
|
784
|
-
// src/gitignore.ts
|
|
785
|
-
var DEFAULT_GITIGNORE = `# dependencies
|
|
786
|
-
node_modules
|
|
787
|
-
.pnp
|
|
788
|
-
.pnp.js
|
|
789
|
-
|
|
790
|
-
# testing
|
|
791
|
-
coverage
|
|
792
|
-
|
|
793
|
-
# next.js
|
|
794
|
-
.next/
|
|
795
|
-
out/
|
|
796
|
-
build
|
|
797
|
-
|
|
798
|
-
# misc
|
|
799
|
-
.DS_Store
|
|
800
|
-
*.pem
|
|
801
|
-
|
|
802
|
-
# debug
|
|
803
|
-
npm-debug.log*
|
|
804
|
-
yarn-debug.log*
|
|
805
|
-
yarn-error.log*
|
|
806
|
-
.pnpm-debug.log*
|
|
807
|
-
|
|
808
|
-
# local env files
|
|
809
|
-
.env.local
|
|
810
|
-
.env.development.local
|
|
811
|
-
.env.test.local
|
|
812
|
-
.env.production.local
|
|
813
|
-
|
|
814
|
-
# turbo
|
|
815
|
-
.turbo
|
|
816
|
-
|
|
817
|
-
dist
|
|
818
|
-
dist-plugin
|
|
819
|
-
dist-web
|
|
820
|
-
vite.config.ts.timestamp-*.mjs`;
|
|
821
|
-
function normalizeLineEndings(value) {
|
|
822
|
-
return value.replace(/\r\n/g, "\n");
|
|
823
|
-
}
|
|
824
|
-
function trimTrailingBlankLines(lines) {
|
|
825
|
-
let end = lines.length;
|
|
826
|
-
while (end > 0 && lines[end - 1] === "") {
|
|
827
|
-
end -= 1;
|
|
828
|
-
}
|
|
829
|
-
return lines.slice(0, end);
|
|
830
|
-
}
|
|
831
|
-
function ensureTrailingNewline(value) {
|
|
832
|
-
return value.endsWith("\n") ? value : `${value}
|
|
833
|
-
`;
|
|
834
|
-
}
|
|
835
|
-
function mergeGitignore(existing) {
|
|
836
|
-
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
837
|
-
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
838
|
-
const merged = [...existingLines];
|
|
839
|
-
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
840
|
-
merged.pop();
|
|
841
|
-
}
|
|
842
|
-
const seen = new Set(merged);
|
|
843
|
-
let appendedNonBlank = false;
|
|
844
|
-
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
845
|
-
const isBlank = line.length === 0;
|
|
846
|
-
if (isBlank) {
|
|
847
|
-
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
848
|
-
continue;
|
|
849
|
-
}
|
|
850
|
-
merged.push("");
|
|
851
|
-
continue;
|
|
852
|
-
}
|
|
853
|
-
if (seen.has(line)) {
|
|
854
|
-
continue;
|
|
855
|
-
}
|
|
856
|
-
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
857
|
-
merged.push("");
|
|
858
|
-
}
|
|
859
|
-
merged.push(line);
|
|
860
|
-
seen.add(line);
|
|
861
|
-
appendedNonBlank = true;
|
|
862
|
-
}
|
|
863
|
-
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// src/updateGitignore.ts
|
|
867
|
-
async function updateGitIgnore(options) {
|
|
868
|
-
const { root, dest, write = true } = options;
|
|
869
|
-
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
870
|
-
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
871
|
-
const existing = await readFileIfExists(outputPath);
|
|
872
|
-
const merged = mergeGitignore(existing);
|
|
873
|
-
if (write && merged !== (existing ?? "")) {
|
|
874
|
-
await writeFile(outputPath, merged);
|
|
875
|
-
logger2.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
876
|
-
}
|
|
877
|
-
return merged;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
// src/createProject.ts
|
|
881
|
-
var moduleDir = posix.dirname(fileURLToPath(import.meta.url));
|
|
882
|
-
async function ensureDotGitignore(root) {
|
|
883
|
-
const gitignorePath = posix.resolve(root, "gitignore");
|
|
884
|
-
const dotGitignorePath = posix.resolve(root, ".gitignore");
|
|
885
|
-
if (!await fs2.pathExists(gitignorePath)) {
|
|
886
|
-
return;
|
|
887
|
-
}
|
|
888
|
-
if (await fs2.pathExists(dotGitignorePath)) {
|
|
889
|
-
await fs2.remove(gitignorePath);
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
await fs2.move(gitignorePath, dotGitignorePath);
|
|
893
|
-
}
|
|
894
|
-
function createEmptyPackageJson() {
|
|
895
|
-
return {
|
|
896
|
-
name: "weapp-vite-app",
|
|
897
|
-
homepage: "https://vite.icebreaker.top/",
|
|
898
|
-
type: "module",
|
|
899
|
-
scripts: {},
|
|
900
|
-
devDependencies: {}
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
async function upsertTailwindcssVersion(pkgJson) {
|
|
904
|
-
if (!pkgJson.devDependencies) {
|
|
905
|
-
return;
|
|
906
|
-
}
|
|
907
|
-
const resolved = await latestVersion("weapp-tailwindcss");
|
|
908
|
-
if (resolved) {
|
|
909
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = resolved;
|
|
910
|
-
} else if (!pkgJson.devDependencies["weapp-tailwindcss"]) {
|
|
911
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = "^4.3.3";
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
function upsertExistingDependencyVersion(pkgJson, packageName, resolvedVersion) {
|
|
915
|
-
if (pkgJson.dependencies?.[packageName]) {
|
|
916
|
-
pkgJson.dependencies[packageName] = resolvedVersion;
|
|
917
|
-
}
|
|
918
|
-
if (pkgJson.devDependencies?.[packageName]) {
|
|
919
|
-
pkgJson.devDependencies[packageName] = resolvedVersion;
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
async function createProject(targetDir = "", templateName = "default" /* default */) {
|
|
923
|
-
const targetTemplateDir = posix.resolve(moduleDir, "../templates", templateName);
|
|
924
|
-
if (!await fs2.pathExists(targetTemplateDir)) {
|
|
925
|
-
logger3.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
|
|
926
|
-
return;
|
|
927
|
-
}
|
|
928
|
-
await fs2.copy(targetTemplateDir, targetDir);
|
|
929
|
-
const templatePackagePath = posix.resolve(targetTemplateDir, "package.json");
|
|
930
|
-
const packageJsonPath = posix.resolve(targetDir, "package.json");
|
|
931
|
-
await ensureDotGitignore(targetDir);
|
|
932
|
-
const pkgJson = await fs2.pathExists(templatePackagePath) ? await fs2.readJSON(templatePackagePath) : createEmptyPackageJson();
|
|
933
|
-
if (!pkgJson.devDependencies) {
|
|
934
|
-
pkgJson.devDependencies = {};
|
|
935
|
-
}
|
|
936
|
-
upsertExistingDependencyVersion(pkgJson, "weapp-vite", version);
|
|
937
|
-
upsertExistingDependencyVersion(pkgJson, "wevu", version2);
|
|
938
|
-
await upsertTailwindcssVersion(pkgJson);
|
|
939
|
-
await writeJsonFile(packageJsonPath, pkgJson);
|
|
940
|
-
await updateGitIgnore({ root: targetDir, write: true });
|
|
941
|
-
logger3.log("\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!");
|
|
942
|
-
}
|
|
943
|
-
|
|
944
766
|
// src/packageJson.ts
|
|
945
|
-
import logger4 from "@weapp-core/logger";
|
|
946
|
-
import { defu, get, set } from "@weapp-core/shared";
|
|
947
767
|
var FALLBACK_DEP_VERSIONS = {
|
|
948
768
|
"miniprogram-api-typings": "^4.1.0",
|
|
949
769
|
"typescript": "^5.9.2",
|
|
@@ -983,7 +803,7 @@ async function createOrUpdatePackageJson(options) {
|
|
|
983
803
|
let packageJson = await readJsonIfExists(packageJsonPath);
|
|
984
804
|
if (!packageJson) {
|
|
985
805
|
packageJson = createDefaultPackageJson();
|
|
986
|
-
|
|
806
|
+
logger2.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${packageJsonFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u521B\u5EFA\u9ED8\u8BA4 package.json ...`);
|
|
987
807
|
}
|
|
988
808
|
set(packageJson, "scripts.dev", `${command} dev`);
|
|
989
809
|
set(packageJson, "scripts.dev:open", `${command} dev -o`);
|
|
@@ -1005,17 +825,17 @@ async function createOrUpdatePackageJson(options) {
|
|
|
1005
825
|
ctx.packageJson.value = packageJson;
|
|
1006
826
|
if (write) {
|
|
1007
827
|
await writeJsonFile(outputPath, packageJson);
|
|
1008
|
-
|
|
828
|
+
logger2.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1009
829
|
}
|
|
1010
830
|
return packageJson;
|
|
1011
831
|
} catch (error) {
|
|
1012
|
-
|
|
832
|
+
logger2.error(`\u26A0\uFE0F \u8BBE\u7F6E ${packageJsonFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1013
833
|
throw error;
|
|
1014
834
|
}
|
|
1015
835
|
}
|
|
1016
836
|
|
|
1017
837
|
// src/projectConfig.ts
|
|
1018
|
-
import
|
|
838
|
+
import logger3 from "@weapp-core/logger";
|
|
1019
839
|
import { defu as defu2, get as get2, set as set2 } from "@weapp-core/shared";
|
|
1020
840
|
function applyProjectConfigDefaults(projectConfig) {
|
|
1021
841
|
set2(projectConfig, "miniprogramRoot", "dist/");
|
|
@@ -1098,7 +918,7 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1098
918
|
applyProjectConfigDefaults(projectConfig);
|
|
1099
919
|
} else {
|
|
1100
920
|
projectConfig = createDefaultProjectConfig();
|
|
1101
|
-
|
|
921
|
+
logger3.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${projectConfigFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u4F7F\u7528\u9ED8\u8BA4\u6A21\u677F\u521B\u5EFA...`);
|
|
1102
922
|
}
|
|
1103
923
|
cb?.(
|
|
1104
924
|
(...args) => {
|
|
@@ -1109,15 +929,114 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1109
929
|
ctx.projectConfig.value = projectConfig;
|
|
1110
930
|
if (write) {
|
|
1111
931
|
await writeJsonFile(outputPath, projectConfig);
|
|
1112
|
-
|
|
932
|
+
logger3.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1113
933
|
}
|
|
1114
934
|
return projectConfig;
|
|
1115
935
|
} catch (error) {
|
|
1116
|
-
|
|
936
|
+
logger3.error(`\u26A0\uFE0F \u8BBE\u7F6E ${projectConfigFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1117
937
|
throw error;
|
|
1118
938
|
}
|
|
1119
939
|
}
|
|
1120
940
|
|
|
941
|
+
// src/updateGitignore.ts
|
|
942
|
+
import logger4 from "@weapp-core/logger";
|
|
943
|
+
|
|
944
|
+
// src/gitignore.ts
|
|
945
|
+
var DEFAULT_GITIGNORE = `# dependencies
|
|
946
|
+
node_modules
|
|
947
|
+
.pnp
|
|
948
|
+
.pnp.js
|
|
949
|
+
|
|
950
|
+
# testing
|
|
951
|
+
coverage
|
|
952
|
+
|
|
953
|
+
# next.js
|
|
954
|
+
.next/
|
|
955
|
+
out/
|
|
956
|
+
build
|
|
957
|
+
|
|
958
|
+
# misc
|
|
959
|
+
.DS_Store
|
|
960
|
+
*.pem
|
|
961
|
+
|
|
962
|
+
# debug
|
|
963
|
+
npm-debug.log*
|
|
964
|
+
yarn-debug.log*
|
|
965
|
+
yarn-error.log*
|
|
966
|
+
.pnpm-debug.log*
|
|
967
|
+
|
|
968
|
+
# local env files
|
|
969
|
+
.env.local
|
|
970
|
+
.env.development.local
|
|
971
|
+
.env.test.local
|
|
972
|
+
.env.production.local
|
|
973
|
+
|
|
974
|
+
# turbo
|
|
975
|
+
.turbo
|
|
976
|
+
|
|
977
|
+
dist
|
|
978
|
+
dist-plugin
|
|
979
|
+
dist-web
|
|
980
|
+
vite.config.ts.timestamp-*.mjs`;
|
|
981
|
+
function normalizeLineEndings(value) {
|
|
982
|
+
return value.replace(/\r\n/g, "\n");
|
|
983
|
+
}
|
|
984
|
+
function trimTrailingBlankLines(lines) {
|
|
985
|
+
let end = lines.length;
|
|
986
|
+
while (end > 0 && lines[end - 1] === "") {
|
|
987
|
+
end -= 1;
|
|
988
|
+
}
|
|
989
|
+
return lines.slice(0, end);
|
|
990
|
+
}
|
|
991
|
+
function ensureTrailingNewline(value) {
|
|
992
|
+
return value.endsWith("\n") ? value : `${value}
|
|
993
|
+
`;
|
|
994
|
+
}
|
|
995
|
+
function mergeGitignore(existing) {
|
|
996
|
+
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
997
|
+
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
998
|
+
const merged = [...existingLines];
|
|
999
|
+
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
1000
|
+
merged.pop();
|
|
1001
|
+
}
|
|
1002
|
+
const seen = new Set(merged);
|
|
1003
|
+
let appendedNonBlank = false;
|
|
1004
|
+
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
1005
|
+
const isBlank = line.length === 0;
|
|
1006
|
+
if (isBlank) {
|
|
1007
|
+
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
merged.push("");
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
if (seen.has(line)) {
|
|
1014
|
+
continue;
|
|
1015
|
+
}
|
|
1016
|
+
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
1017
|
+
merged.push("");
|
|
1018
|
+
}
|
|
1019
|
+
merged.push(line);
|
|
1020
|
+
seen.add(line);
|
|
1021
|
+
appendedNonBlank = true;
|
|
1022
|
+
}
|
|
1023
|
+
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// src/updateGitignore.ts
|
|
1027
|
+
async function updateGitIgnore(options) {
|
|
1028
|
+
const { root, dest, write = true } = options;
|
|
1029
|
+
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
1030
|
+
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
1031
|
+
const existing = await readFileIfExists(outputPath);
|
|
1032
|
+
const merged = mergeGitignore(existing);
|
|
1033
|
+
if (write && merged !== (existing ?? "")) {
|
|
1034
|
+
await writeFile(outputPath, merged);
|
|
1035
|
+
logger4.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1036
|
+
}
|
|
1037
|
+
return merged;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1121
1040
|
// src/index.ts
|
|
1122
1041
|
async function initConfig(options) {
|
|
1123
1042
|
const { root = process2.cwd(), command } = options;
|
|
@@ -1132,10 +1051,8 @@ async function initConfig(options) {
|
|
|
1132
1051
|
return ctx;
|
|
1133
1052
|
}
|
|
1134
1053
|
export {
|
|
1135
|
-
TemplateName,
|
|
1136
1054
|
createOrUpdatePackageJson,
|
|
1137
1055
|
createOrUpdateProjectConfig,
|
|
1138
|
-
createProject,
|
|
1139
1056
|
initConfig,
|
|
1140
1057
|
initTsDtsFile,
|
|
1141
1058
|
initTsJsonFiles,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/init",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"description": "@weapp-core/init",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,19 +34,13 @@
|
|
|
34
34
|
"types": "./src/index.ts"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
|
-
"dist"
|
|
38
|
-
"templates"
|
|
37
|
+
"dist"
|
|
39
38
|
],
|
|
40
39
|
"dependencies": {
|
|
41
40
|
"fs-extra": "^11.3.3",
|
|
42
41
|
"@weapp-core/logger": "^2.0.0",
|
|
43
42
|
"@weapp-core/shared": "^2.0.1"
|
|
44
43
|
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@types/semver": "^7.7.1",
|
|
47
|
-
"fdir": "^6.5.0",
|
|
48
|
-
"semver": "^7.7.3"
|
|
49
|
-
},
|
|
50
44
|
"scripts": {
|
|
51
45
|
"dev": "tsup --watch --sourcemap",
|
|
52
46
|
"build": "tsup",
|
|
@@ -55,7 +49,6 @@
|
|
|
55
49
|
"release": "pnpm publish",
|
|
56
50
|
"lint": "eslint .",
|
|
57
51
|
"lint:fix": "eslint . --fix",
|
|
58
|
-
"sync": "cnpm sync @weapp-core/init"
|
|
59
|
-
"prepublish": "tsx scripts/prepublish.ts"
|
|
52
|
+
"sync": "cnpm sync @weapp-core/init"
|
|
60
53
|
}
|
|
61
54
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# weapp-vite-template
|
|
2
|
-
|
|
3
|
-
`weapp-vite` 模板
|
|
4
|
-
|
|
5
|
-
## 使用方式
|
|
6
|
-
|
|
7
|
-
### 开发
|
|
8
|
-
|
|
9
|
-
- `pnpm dev`
|
|
10
|
-
|
|
11
|
-
- `pnpm dev --open` 可以打包并直接启动微信开发者工具
|
|
12
|
-
|
|
13
|
-
### 构建
|
|
14
|
-
|
|
15
|
-
`pnpm build`
|
|
16
|
-
|
|
17
|
-
### 打开微信开发者工具
|
|
18
|
-
|
|
19
|
-
`pnpm open`
|
|
20
|
-
|
|
21
|
-
### 生成组件/页面
|
|
22
|
-
|
|
23
|
-
`pnpm g path/to/your/component`
|
|
24
|
-
|
|
25
|
-
## 文档地址
|
|
26
|
-
|
|
27
|
-
0. `weapp-vite`: https://vite.icebreaker.top/
|
|
28
|
-
1. `weapp-tailwindcss`: https://tw.icebreaker.top/
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# dependencies
|
|
2
|
-
node_modules
|
|
3
|
-
.pnp
|
|
4
|
-
.pnp.js
|
|
5
|
-
|
|
6
|
-
# testing
|
|
7
|
-
coverage
|
|
8
|
-
|
|
9
|
-
# next.js
|
|
10
|
-
.next/
|
|
11
|
-
out/
|
|
12
|
-
build
|
|
13
|
-
|
|
14
|
-
# misc
|
|
15
|
-
.DS_Store
|
|
16
|
-
*.pem
|
|
17
|
-
|
|
18
|
-
# debug
|
|
19
|
-
npm-debug.log*
|
|
20
|
-
yarn-debug.log*
|
|
21
|
-
yarn-error.log*
|
|
22
|
-
.pnpm-debug.log*
|
|
23
|
-
|
|
24
|
-
# local env files
|
|
25
|
-
.env.local
|
|
26
|
-
.env.development.local
|
|
27
|
-
.env.test.local
|
|
28
|
-
.env.production.local
|
|
29
|
-
|
|
30
|
-
# turbo
|
|
31
|
-
.turbo
|
|
32
|
-
|
|
33
|
-
dist
|
|
34
|
-
vite.config.ts.timestamp-*.mjs
|
|
35
|
-
dist-web
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "weapp-vite-template",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "1.0.3",
|
|
5
|
-
"private": true,
|
|
6
|
-
"description": "原生微信小程序 weapp-vite 模板",
|
|
7
|
-
"author": "ice breaker <1324318532@qq.com>",
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/weapp-vite/weapp-vite.git",
|
|
12
|
-
"directory": "templates/weapp-vite-template"
|
|
13
|
-
},
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/weapp-vite/weapp-vite/issues"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"dev": "weapp-vite dev",
|
|
20
|
-
"dev:open": "weapp-vite dev -o",
|
|
21
|
-
"build": "weapp-vite build",
|
|
22
|
-
"open": "weapp-vite open",
|
|
23
|
-
"g": "weapp-vite generate"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"miniprogram-api-typings": "^4.1.2",
|
|
27
|
-
"sass": "^1.97.1",
|
|
28
|
-
"typescript": "^5.9.3",
|
|
29
|
-
"weapp-vite": "workspace:*"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "项目配置文件",
|
|
3
|
-
"miniprogramRoot": "dist/",
|
|
4
|
-
"compileType": "miniprogram",
|
|
5
|
-
"setting": {
|
|
6
|
-
"babelSetting": {
|
|
7
|
-
"ignore": [],
|
|
8
|
-
"disablePlugins": [],
|
|
9
|
-
"outputPath": ""
|
|
10
|
-
},
|
|
11
|
-
"coverView": false,
|
|
12
|
-
"postcss": false,
|
|
13
|
-
"minified": false,
|
|
14
|
-
"enhance": false,
|
|
15
|
-
"showShadowRootInWxmlPanel": false,
|
|
16
|
-
"packNpmRelationList": [
|
|
17
|
-
{
|
|
18
|
-
"packageJsonPath": "./package.json",
|
|
19
|
-
"miniprogramNpmDistDir": "./dist"
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"ignoreUploadUnusedFiles": true,
|
|
23
|
-
"compileHotReLoad": false,
|
|
24
|
-
"skylineRenderEnable": true,
|
|
25
|
-
"packNpmManually": true,
|
|
26
|
-
"es6": true
|
|
27
|
-
},
|
|
28
|
-
"simulatorType": "wechat",
|
|
29
|
-
"simulatorPluginLibVersion": {},
|
|
30
|
-
"condition": {},
|
|
31
|
-
"srcMiniprogramRoot": "dist/",
|
|
32
|
-
"editorSetting": {
|
|
33
|
-
"tabIndent": "insertSpaces",
|
|
34
|
-
"tabSize": 2
|
|
35
|
-
},
|
|
36
|
-
"libVersion": "2.32.3",
|
|
37
|
-
"packOptions": {
|
|
38
|
-
"ignore": [],
|
|
39
|
-
"include": []
|
|
40
|
-
},
|
|
41
|
-
"appid": "wx6ffee4673b257014"
|
|
42
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
|
3
|
-
"projectname": "weapp-vite-template",
|
|
4
|
-
"setting": {
|
|
5
|
-
"compileHotReLoad": true
|
|
6
|
-
},
|
|
7
|
-
"libVersion": "3.9.0"
|
|
8
|
-
}
|
|
Binary file
|
|
File without changes
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
.hello-card {
|
|
2
|
-
width: 640rpx;
|
|
3
|
-
margin: 48rpx auto;
|
|
4
|
-
padding: 32rpx;
|
|
5
|
-
border-radius: 32rpx;
|
|
6
|
-
background: #ffffff;
|
|
7
|
-
box-shadow: 0 20rpx 60rpx rgba(15, 23, 42, 0.08);
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
gap: 24rpx;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.hello-title {
|
|
14
|
-
font-size: 36rpx;
|
|
15
|
-
font-weight: 600;
|
|
16
|
-
color: #2563eb;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.hello-body {
|
|
20
|
-
font-size: 28rpx;
|
|
21
|
-
line-height: 1.6;
|
|
22
|
-
color: #334155;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.hello-actions {
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-wrap: wrap;
|
|
28
|
-
gap: 20rpx;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.hello-button {
|
|
32
|
-
padding: 16rpx 32rpx;
|
|
33
|
-
border-radius: 999rpx;
|
|
34
|
-
background: #2563eb;
|
|
35
|
-
color: #ffffff;
|
|
36
|
-
font-size: 26rpx;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.hello-button--ghost {
|
|
40
|
-
background: #e2e8f0;
|
|
41
|
-
color: #1e293b;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.hello-tip {
|
|
45
|
-
font-size: 24rpx;
|
|
46
|
-
color: #94a3b8;
|
|
47
|
-
}
|