@weapp-core/init 4.1.1 → 5.0.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/dist/index.cjs +110 -204
- package/dist/index.d.cts +1 -13
- package/dist/index.d.ts +1 -13
- package/dist/index.js +110 -196
- package/package.json +5 -12
- 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 -35
- package/templates/wevu-tdesign/src/components/HelloWorld/index.vue +0 -23
- package/templates/wevu-tdesign/src/pages/index/index.vue +0 -165
- 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 -62
- 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
|
@@ -500,9 +500,6 @@ function getDefaultTsconfigAppJson() {
|
|
|
500
500
|
paths: {
|
|
501
501
|
"@/*": [
|
|
502
502
|
"./src/*"
|
|
503
|
-
],
|
|
504
|
-
"take:@/*": [
|
|
505
|
-
"./src/*"
|
|
506
503
|
]
|
|
507
504
|
},
|
|
508
505
|
resolveJsonModule: true,
|
|
@@ -714,27 +711,12 @@ async function initTsJsonFiles(options) {
|
|
|
714
711
|
};
|
|
715
712
|
}
|
|
716
713
|
|
|
717
|
-
// src/
|
|
718
|
-
import
|
|
719
|
-
import
|
|
720
|
-
import fs2 from "fs-extra";
|
|
714
|
+
// src/packageJson.ts
|
|
715
|
+
import logger2 from "@weapp-core/logger";
|
|
716
|
+
import { defu, get, set } from "@weapp-core/shared";
|
|
721
717
|
|
|
722
718
|
// ../../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 || {});
|
|
719
|
+
var version = "6.1.5";
|
|
738
720
|
|
|
739
721
|
// src/npm.ts
|
|
740
722
|
import https from "https";
|
|
@@ -778,172 +760,7 @@ async function latestVersion(packageName, prefix = "^", fetch = getLatestVersion
|
|
|
778
760
|
}
|
|
779
761
|
}
|
|
780
762
|
|
|
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
763
|
// src/packageJson.ts
|
|
945
|
-
import logger4 from "@weapp-core/logger";
|
|
946
|
-
import { defu, get, set } from "@weapp-core/shared";
|
|
947
764
|
var FALLBACK_DEP_VERSIONS = {
|
|
948
765
|
"miniprogram-api-typings": "^4.1.0",
|
|
949
766
|
"typescript": "^5.9.2",
|
|
@@ -983,7 +800,7 @@ async function createOrUpdatePackageJson(options) {
|
|
|
983
800
|
let packageJson = await readJsonIfExists(packageJsonPath);
|
|
984
801
|
if (!packageJson) {
|
|
985
802
|
packageJson = createDefaultPackageJson();
|
|
986
|
-
|
|
803
|
+
logger2.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${packageJsonFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u521B\u5EFA\u9ED8\u8BA4 package.json ...`);
|
|
987
804
|
}
|
|
988
805
|
set(packageJson, "scripts.dev", `${command} dev`);
|
|
989
806
|
set(packageJson, "scripts.dev:open", `${command} dev -o`);
|
|
@@ -1005,17 +822,17 @@ async function createOrUpdatePackageJson(options) {
|
|
|
1005
822
|
ctx.packageJson.value = packageJson;
|
|
1006
823
|
if (write) {
|
|
1007
824
|
await writeJsonFile(outputPath, packageJson);
|
|
1008
|
-
|
|
825
|
+
logger2.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1009
826
|
}
|
|
1010
827
|
return packageJson;
|
|
1011
828
|
} catch (error) {
|
|
1012
|
-
|
|
829
|
+
logger2.error(`\u26A0\uFE0F \u8BBE\u7F6E ${packageJsonFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1013
830
|
throw error;
|
|
1014
831
|
}
|
|
1015
832
|
}
|
|
1016
833
|
|
|
1017
834
|
// src/projectConfig.ts
|
|
1018
|
-
import
|
|
835
|
+
import logger3 from "@weapp-core/logger";
|
|
1019
836
|
import { defu as defu2, get as get2, set as set2 } from "@weapp-core/shared";
|
|
1020
837
|
function applyProjectConfigDefaults(projectConfig) {
|
|
1021
838
|
set2(projectConfig, "miniprogramRoot", "dist/");
|
|
@@ -1098,7 +915,7 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1098
915
|
applyProjectConfigDefaults(projectConfig);
|
|
1099
916
|
} else {
|
|
1100
917
|
projectConfig = createDefaultProjectConfig();
|
|
1101
|
-
|
|
918
|
+
logger3.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${projectConfigFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u4F7F\u7528\u9ED8\u8BA4\u6A21\u677F\u521B\u5EFA...`);
|
|
1102
919
|
}
|
|
1103
920
|
cb?.(
|
|
1104
921
|
(...args) => {
|
|
@@ -1109,15 +926,114 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1109
926
|
ctx.projectConfig.value = projectConfig;
|
|
1110
927
|
if (write) {
|
|
1111
928
|
await writeJsonFile(outputPath, projectConfig);
|
|
1112
|
-
|
|
929
|
+
logger3.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1113
930
|
}
|
|
1114
931
|
return projectConfig;
|
|
1115
932
|
} catch (error) {
|
|
1116
|
-
|
|
933
|
+
logger3.error(`\u26A0\uFE0F \u8BBE\u7F6E ${projectConfigFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1117
934
|
throw error;
|
|
1118
935
|
}
|
|
1119
936
|
}
|
|
1120
937
|
|
|
938
|
+
// src/updateGitignore.ts
|
|
939
|
+
import logger4 from "@weapp-core/logger";
|
|
940
|
+
|
|
941
|
+
// src/gitignore.ts
|
|
942
|
+
var DEFAULT_GITIGNORE = `# dependencies
|
|
943
|
+
node_modules
|
|
944
|
+
.pnp
|
|
945
|
+
.pnp.js
|
|
946
|
+
|
|
947
|
+
# testing
|
|
948
|
+
coverage
|
|
949
|
+
|
|
950
|
+
# next.js
|
|
951
|
+
.next/
|
|
952
|
+
out/
|
|
953
|
+
build
|
|
954
|
+
|
|
955
|
+
# misc
|
|
956
|
+
.DS_Store
|
|
957
|
+
*.pem
|
|
958
|
+
|
|
959
|
+
# debug
|
|
960
|
+
npm-debug.log*
|
|
961
|
+
yarn-debug.log*
|
|
962
|
+
yarn-error.log*
|
|
963
|
+
.pnpm-debug.log*
|
|
964
|
+
|
|
965
|
+
# local env files
|
|
966
|
+
.env.local
|
|
967
|
+
.env.development.local
|
|
968
|
+
.env.test.local
|
|
969
|
+
.env.production.local
|
|
970
|
+
|
|
971
|
+
# turbo
|
|
972
|
+
.turbo
|
|
973
|
+
|
|
974
|
+
dist
|
|
975
|
+
dist-plugin
|
|
976
|
+
dist-web
|
|
977
|
+
vite.config.ts.timestamp-*.mjs`;
|
|
978
|
+
function normalizeLineEndings(value) {
|
|
979
|
+
return value.replace(/\r\n/g, "\n");
|
|
980
|
+
}
|
|
981
|
+
function trimTrailingBlankLines(lines) {
|
|
982
|
+
let end = lines.length;
|
|
983
|
+
while (end > 0 && lines[end - 1] === "") {
|
|
984
|
+
end -= 1;
|
|
985
|
+
}
|
|
986
|
+
return lines.slice(0, end);
|
|
987
|
+
}
|
|
988
|
+
function ensureTrailingNewline(value) {
|
|
989
|
+
return value.endsWith("\n") ? value : `${value}
|
|
990
|
+
`;
|
|
991
|
+
}
|
|
992
|
+
function mergeGitignore(existing) {
|
|
993
|
+
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
994
|
+
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
995
|
+
const merged = [...existingLines];
|
|
996
|
+
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
997
|
+
merged.pop();
|
|
998
|
+
}
|
|
999
|
+
const seen = new Set(merged);
|
|
1000
|
+
let appendedNonBlank = false;
|
|
1001
|
+
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
1002
|
+
const isBlank = line.length === 0;
|
|
1003
|
+
if (isBlank) {
|
|
1004
|
+
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
merged.push("");
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
if (seen.has(line)) {
|
|
1011
|
+
continue;
|
|
1012
|
+
}
|
|
1013
|
+
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
1014
|
+
merged.push("");
|
|
1015
|
+
}
|
|
1016
|
+
merged.push(line);
|
|
1017
|
+
seen.add(line);
|
|
1018
|
+
appendedNonBlank = true;
|
|
1019
|
+
}
|
|
1020
|
+
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
// src/updateGitignore.ts
|
|
1024
|
+
async function updateGitIgnore(options) {
|
|
1025
|
+
const { root, dest, write = true } = options;
|
|
1026
|
+
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
1027
|
+
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
1028
|
+
const existing = await readFileIfExists(outputPath);
|
|
1029
|
+
const merged = mergeGitignore(existing);
|
|
1030
|
+
if (write && merged !== (existing ?? "")) {
|
|
1031
|
+
await writeFile(outputPath, merged);
|
|
1032
|
+
logger4.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1033
|
+
}
|
|
1034
|
+
return merged;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1121
1037
|
// src/index.ts
|
|
1122
1038
|
async function initConfig(options) {
|
|
1123
1039
|
const { root = process2.cwd(), command } = options;
|
|
@@ -1132,10 +1048,8 @@ async function initConfig(options) {
|
|
|
1132
1048
|
return ctx;
|
|
1133
1049
|
}
|
|
1134
1050
|
export {
|
|
1135
|
-
TemplateName,
|
|
1136
1051
|
createOrUpdatePackageJson,
|
|
1137
1052
|
createOrUpdateProjectConfig,
|
|
1138
|
-
createProject,
|
|
1139
1053
|
initConfig,
|
|
1140
1054
|
initTsDtsFile,
|
|
1141
1055
|
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.1",
|
|
5
5
|
"description": "@weapp-core/init",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,18 +34,12 @@
|
|
|
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
|
-
"@weapp-core/
|
|
43
|
-
"@weapp-core/
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@types/semver": "^7.7.1",
|
|
47
|
-
"fdir": "^6.5.0",
|
|
48
|
-
"semver": "^7.7.3"
|
|
41
|
+
"@weapp-core/shared": "^2.0.1",
|
|
42
|
+
"@weapp-core/logger": "^2.0.0"
|
|
49
43
|
},
|
|
50
44
|
"scripts": {
|
|
51
45
|
"dev": "tsup --watch --sourcemap",
|
|
@@ -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
|
-
}
|