@weapp-core/init 4.1.1 → 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 -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.cjs
CHANGED
|
@@ -30,10 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
TemplateName: () => TemplateName,
|
|
34
33
|
createOrUpdatePackageJson: () => createOrUpdatePackageJson,
|
|
35
34
|
createOrUpdateProjectConfig: () => createOrUpdateProjectConfig,
|
|
36
|
-
createProject: () => createProject,
|
|
37
35
|
initConfig: () => initConfig,
|
|
38
36
|
initTsDtsFile: () => initTsDtsFile,
|
|
39
37
|
initTsJsonFiles: () => initTsJsonFiles,
|
|
@@ -41,12 +39,6 @@ __export(index_exports, {
|
|
|
41
39
|
resetContext: () => resetContext
|
|
42
40
|
});
|
|
43
41
|
module.exports = __toCommonJS(index_exports);
|
|
44
|
-
|
|
45
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.8_jiti@2.6.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js
|
|
46
|
-
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
47
|
-
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
48
|
-
|
|
49
|
-
// src/index.ts
|
|
50
42
|
var import_node_process = __toESM(require("process"), 1);
|
|
51
43
|
|
|
52
44
|
// src/configFiles.ts
|
|
@@ -762,27 +754,12 @@ async function initTsJsonFiles(options) {
|
|
|
762
754
|
};
|
|
763
755
|
}
|
|
764
756
|
|
|
765
|
-
// src/
|
|
766
|
-
var
|
|
767
|
-
var
|
|
768
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
757
|
+
// src/packageJson.ts
|
|
758
|
+
var import_logger2 = __toESM(require("@weapp-core/logger"), 1);
|
|
759
|
+
var import_shared = require("@weapp-core/shared");
|
|
769
760
|
|
|
770
761
|
// ../../packages/weapp-vite/package.json
|
|
771
|
-
var version = "6.1.
|
|
772
|
-
|
|
773
|
-
// ../../packages/wevu/package.json
|
|
774
|
-
var version2 = "1.0.1";
|
|
775
|
-
|
|
776
|
-
// src/enums.ts
|
|
777
|
-
var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
|
|
778
|
-
TemplateName2["default"] = "default";
|
|
779
|
-
TemplateName2["wevu"] = "wevu";
|
|
780
|
-
TemplateName2["tailwindcss"] = "tailwindcss";
|
|
781
|
-
TemplateName2["vant"] = "vant";
|
|
782
|
-
TemplateName2["tdesign"] = "tdesign";
|
|
783
|
-
TemplateName2["wevuTdesign"] = "wevu-tdesign";
|
|
784
|
-
return TemplateName2;
|
|
785
|
-
})(TemplateName || {});
|
|
762
|
+
var version = "6.1.4";
|
|
786
763
|
|
|
787
764
|
// src/npm.ts
|
|
788
765
|
var import_node_https = __toESM(require("https"), 1);
|
|
@@ -826,172 +803,7 @@ async function latestVersion(packageName, prefix = "^", fetch = getLatestVersion
|
|
|
826
803
|
}
|
|
827
804
|
}
|
|
828
805
|
|
|
829
|
-
// src/updateGitignore.ts
|
|
830
|
-
var import_logger2 = __toESM(require("@weapp-core/logger"), 1);
|
|
831
|
-
|
|
832
|
-
// src/gitignore.ts
|
|
833
|
-
var DEFAULT_GITIGNORE = `# dependencies
|
|
834
|
-
node_modules
|
|
835
|
-
.pnp
|
|
836
|
-
.pnp.js
|
|
837
|
-
|
|
838
|
-
# testing
|
|
839
|
-
coverage
|
|
840
|
-
|
|
841
|
-
# next.js
|
|
842
|
-
.next/
|
|
843
|
-
out/
|
|
844
|
-
build
|
|
845
|
-
|
|
846
|
-
# misc
|
|
847
|
-
.DS_Store
|
|
848
|
-
*.pem
|
|
849
|
-
|
|
850
|
-
# debug
|
|
851
|
-
npm-debug.log*
|
|
852
|
-
yarn-debug.log*
|
|
853
|
-
yarn-error.log*
|
|
854
|
-
.pnpm-debug.log*
|
|
855
|
-
|
|
856
|
-
# local env files
|
|
857
|
-
.env.local
|
|
858
|
-
.env.development.local
|
|
859
|
-
.env.test.local
|
|
860
|
-
.env.production.local
|
|
861
|
-
|
|
862
|
-
# turbo
|
|
863
|
-
.turbo
|
|
864
|
-
|
|
865
|
-
dist
|
|
866
|
-
dist-plugin
|
|
867
|
-
dist-web
|
|
868
|
-
vite.config.ts.timestamp-*.mjs`;
|
|
869
|
-
function normalizeLineEndings(value) {
|
|
870
|
-
return value.replace(/\r\n/g, "\n");
|
|
871
|
-
}
|
|
872
|
-
function trimTrailingBlankLines(lines) {
|
|
873
|
-
let end = lines.length;
|
|
874
|
-
while (end > 0 && lines[end - 1] === "") {
|
|
875
|
-
end -= 1;
|
|
876
|
-
}
|
|
877
|
-
return lines.slice(0, end);
|
|
878
|
-
}
|
|
879
|
-
function ensureTrailingNewline(value) {
|
|
880
|
-
return value.endsWith("\n") ? value : `${value}
|
|
881
|
-
`;
|
|
882
|
-
}
|
|
883
|
-
function mergeGitignore(existing) {
|
|
884
|
-
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
885
|
-
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
886
|
-
const merged = [...existingLines];
|
|
887
|
-
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
888
|
-
merged.pop();
|
|
889
|
-
}
|
|
890
|
-
const seen = new Set(merged);
|
|
891
|
-
let appendedNonBlank = false;
|
|
892
|
-
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
893
|
-
const isBlank = line.length === 0;
|
|
894
|
-
if (isBlank) {
|
|
895
|
-
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
896
|
-
continue;
|
|
897
|
-
}
|
|
898
|
-
merged.push("");
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
if (seen.has(line)) {
|
|
902
|
-
continue;
|
|
903
|
-
}
|
|
904
|
-
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
905
|
-
merged.push("");
|
|
906
|
-
}
|
|
907
|
-
merged.push(line);
|
|
908
|
-
seen.add(line);
|
|
909
|
-
appendedNonBlank = true;
|
|
910
|
-
}
|
|
911
|
-
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
// src/updateGitignore.ts
|
|
915
|
-
async function updateGitIgnore(options) {
|
|
916
|
-
const { root, dest, write = true } = options;
|
|
917
|
-
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
918
|
-
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
919
|
-
const existing = await readFileIfExists(outputPath);
|
|
920
|
-
const merged = mergeGitignore(existing);
|
|
921
|
-
if (write && merged !== (existing ?? "")) {
|
|
922
|
-
await writeFile(outputPath, merged);
|
|
923
|
-
import_logger2.default.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
924
|
-
}
|
|
925
|
-
return merged;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// src/createProject.ts
|
|
929
|
-
var moduleDir = posix.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
930
|
-
async function ensureDotGitignore(root) {
|
|
931
|
-
const gitignorePath = posix.resolve(root, "gitignore");
|
|
932
|
-
const dotGitignorePath = posix.resolve(root, ".gitignore");
|
|
933
|
-
if (!await import_fs_extra2.default.pathExists(gitignorePath)) {
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
if (await import_fs_extra2.default.pathExists(dotGitignorePath)) {
|
|
937
|
-
await import_fs_extra2.default.remove(gitignorePath);
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
await import_fs_extra2.default.move(gitignorePath, dotGitignorePath);
|
|
941
|
-
}
|
|
942
|
-
function createEmptyPackageJson() {
|
|
943
|
-
return {
|
|
944
|
-
name: "weapp-vite-app",
|
|
945
|
-
homepage: "https://vite.icebreaker.top/",
|
|
946
|
-
type: "module",
|
|
947
|
-
scripts: {},
|
|
948
|
-
devDependencies: {}
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
async function upsertTailwindcssVersion(pkgJson) {
|
|
952
|
-
if (!pkgJson.devDependencies) {
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
const resolved = await latestVersion("weapp-tailwindcss");
|
|
956
|
-
if (resolved) {
|
|
957
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = resolved;
|
|
958
|
-
} else if (!pkgJson.devDependencies["weapp-tailwindcss"]) {
|
|
959
|
-
pkgJson.devDependencies["weapp-tailwindcss"] = "^4.3.3";
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
function upsertExistingDependencyVersion(pkgJson, packageName, resolvedVersion) {
|
|
963
|
-
if (pkgJson.dependencies?.[packageName]) {
|
|
964
|
-
pkgJson.dependencies[packageName] = resolvedVersion;
|
|
965
|
-
}
|
|
966
|
-
if (pkgJson.devDependencies?.[packageName]) {
|
|
967
|
-
pkgJson.devDependencies[packageName] = resolvedVersion;
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
async function createProject(targetDir = "", templateName = "default" /* default */) {
|
|
971
|
-
const targetTemplateDir = posix.resolve(moduleDir, "../templates", templateName);
|
|
972
|
-
if (!await import_fs_extra2.default.pathExists(targetTemplateDir)) {
|
|
973
|
-
import_logger3.default.warn(`\u6CA1\u6709\u627E\u5230 ${templateName} \u6A21\u677F!`);
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
976
|
-
await import_fs_extra2.default.copy(targetTemplateDir, targetDir);
|
|
977
|
-
const templatePackagePath = posix.resolve(targetTemplateDir, "package.json");
|
|
978
|
-
const packageJsonPath = posix.resolve(targetDir, "package.json");
|
|
979
|
-
await ensureDotGitignore(targetDir);
|
|
980
|
-
const pkgJson = await import_fs_extra2.default.pathExists(templatePackagePath) ? await import_fs_extra2.default.readJSON(templatePackagePath) : createEmptyPackageJson();
|
|
981
|
-
if (!pkgJson.devDependencies) {
|
|
982
|
-
pkgJson.devDependencies = {};
|
|
983
|
-
}
|
|
984
|
-
upsertExistingDependencyVersion(pkgJson, "weapp-vite", version);
|
|
985
|
-
upsertExistingDependencyVersion(pkgJson, "wevu", version2);
|
|
986
|
-
await upsertTailwindcssVersion(pkgJson);
|
|
987
|
-
await writeJsonFile(packageJsonPath, pkgJson);
|
|
988
|
-
await updateGitIgnore({ root: targetDir, write: true });
|
|
989
|
-
import_logger3.default.log("\u2728 \u521B\u5EFA\u6A21\u677F\u6210\u529F!");
|
|
990
|
-
}
|
|
991
|
-
|
|
992
806
|
// src/packageJson.ts
|
|
993
|
-
var import_logger4 = __toESM(require("@weapp-core/logger"), 1);
|
|
994
|
-
var import_shared = require("@weapp-core/shared");
|
|
995
807
|
var FALLBACK_DEP_VERSIONS = {
|
|
996
808
|
"miniprogram-api-typings": "^4.1.0",
|
|
997
809
|
"typescript": "^5.9.2",
|
|
@@ -1031,7 +843,7 @@ async function createOrUpdatePackageJson(options) {
|
|
|
1031
843
|
let packageJson = await readJsonIfExists(packageJsonPath);
|
|
1032
844
|
if (!packageJson) {
|
|
1033
845
|
packageJson = createDefaultPackageJson();
|
|
1034
|
-
|
|
846
|
+
import_logger2.default.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${packageJsonFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u521B\u5EFA\u9ED8\u8BA4 package.json ...`);
|
|
1035
847
|
}
|
|
1036
848
|
(0, import_shared.set)(packageJson, "scripts.dev", `${command} dev`);
|
|
1037
849
|
(0, import_shared.set)(packageJson, "scripts.dev:open", `${command} dev -o`);
|
|
@@ -1053,17 +865,17 @@ async function createOrUpdatePackageJson(options) {
|
|
|
1053
865
|
ctx.packageJson.value = packageJson;
|
|
1054
866
|
if (write) {
|
|
1055
867
|
await writeJsonFile(outputPath, packageJson);
|
|
1056
|
-
|
|
868
|
+
import_logger2.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1057
869
|
}
|
|
1058
870
|
return packageJson;
|
|
1059
871
|
} catch (error) {
|
|
1060
|
-
|
|
872
|
+
import_logger2.default.error(`\u26A0\uFE0F \u8BBE\u7F6E ${packageJsonFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1061
873
|
throw error;
|
|
1062
874
|
}
|
|
1063
875
|
}
|
|
1064
876
|
|
|
1065
877
|
// src/projectConfig.ts
|
|
1066
|
-
var
|
|
878
|
+
var import_logger3 = __toESM(require("@weapp-core/logger"), 1);
|
|
1067
879
|
var import_shared2 = require("@weapp-core/shared");
|
|
1068
880
|
function applyProjectConfigDefaults(projectConfig) {
|
|
1069
881
|
(0, import_shared2.set)(projectConfig, "miniprogramRoot", "dist/");
|
|
@@ -1146,7 +958,7 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1146
958
|
applyProjectConfigDefaults(projectConfig);
|
|
1147
959
|
} else {
|
|
1148
960
|
projectConfig = createDefaultProjectConfig();
|
|
1149
|
-
|
|
961
|
+
import_logger3.default.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${projectConfigFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u4F7F\u7528\u9ED8\u8BA4\u6A21\u677F\u521B\u5EFA...`);
|
|
1150
962
|
}
|
|
1151
963
|
cb?.(
|
|
1152
964
|
(...args) => {
|
|
@@ -1157,15 +969,114 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1157
969
|
ctx.projectConfig.value = projectConfig;
|
|
1158
970
|
if (write) {
|
|
1159
971
|
await writeJsonFile(outputPath, projectConfig);
|
|
1160
|
-
|
|
972
|
+
import_logger3.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1161
973
|
}
|
|
1162
974
|
return projectConfig;
|
|
1163
975
|
} catch (error) {
|
|
1164
|
-
|
|
976
|
+
import_logger3.default.error(`\u26A0\uFE0F \u8BBE\u7F6E ${projectConfigFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1165
977
|
throw error;
|
|
1166
978
|
}
|
|
1167
979
|
}
|
|
1168
980
|
|
|
981
|
+
// src/updateGitignore.ts
|
|
982
|
+
var import_logger4 = __toESM(require("@weapp-core/logger"), 1);
|
|
983
|
+
|
|
984
|
+
// src/gitignore.ts
|
|
985
|
+
var DEFAULT_GITIGNORE = `# dependencies
|
|
986
|
+
node_modules
|
|
987
|
+
.pnp
|
|
988
|
+
.pnp.js
|
|
989
|
+
|
|
990
|
+
# testing
|
|
991
|
+
coverage
|
|
992
|
+
|
|
993
|
+
# next.js
|
|
994
|
+
.next/
|
|
995
|
+
out/
|
|
996
|
+
build
|
|
997
|
+
|
|
998
|
+
# misc
|
|
999
|
+
.DS_Store
|
|
1000
|
+
*.pem
|
|
1001
|
+
|
|
1002
|
+
# debug
|
|
1003
|
+
npm-debug.log*
|
|
1004
|
+
yarn-debug.log*
|
|
1005
|
+
yarn-error.log*
|
|
1006
|
+
.pnpm-debug.log*
|
|
1007
|
+
|
|
1008
|
+
# local env files
|
|
1009
|
+
.env.local
|
|
1010
|
+
.env.development.local
|
|
1011
|
+
.env.test.local
|
|
1012
|
+
.env.production.local
|
|
1013
|
+
|
|
1014
|
+
# turbo
|
|
1015
|
+
.turbo
|
|
1016
|
+
|
|
1017
|
+
dist
|
|
1018
|
+
dist-plugin
|
|
1019
|
+
dist-web
|
|
1020
|
+
vite.config.ts.timestamp-*.mjs`;
|
|
1021
|
+
function normalizeLineEndings(value) {
|
|
1022
|
+
return value.replace(/\r\n/g, "\n");
|
|
1023
|
+
}
|
|
1024
|
+
function trimTrailingBlankLines(lines) {
|
|
1025
|
+
let end = lines.length;
|
|
1026
|
+
while (end > 0 && lines[end - 1] === "") {
|
|
1027
|
+
end -= 1;
|
|
1028
|
+
}
|
|
1029
|
+
return lines.slice(0, end);
|
|
1030
|
+
}
|
|
1031
|
+
function ensureTrailingNewline(value) {
|
|
1032
|
+
return value.endsWith("\n") ? value : `${value}
|
|
1033
|
+
`;
|
|
1034
|
+
}
|
|
1035
|
+
function mergeGitignore(existing) {
|
|
1036
|
+
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
1037
|
+
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
1038
|
+
const merged = [...existingLines];
|
|
1039
|
+
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
1040
|
+
merged.pop();
|
|
1041
|
+
}
|
|
1042
|
+
const seen = new Set(merged);
|
|
1043
|
+
let appendedNonBlank = false;
|
|
1044
|
+
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
1045
|
+
const isBlank = line.length === 0;
|
|
1046
|
+
if (isBlank) {
|
|
1047
|
+
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
merged.push("");
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
if (seen.has(line)) {
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
1057
|
+
merged.push("");
|
|
1058
|
+
}
|
|
1059
|
+
merged.push(line);
|
|
1060
|
+
seen.add(line);
|
|
1061
|
+
appendedNonBlank = true;
|
|
1062
|
+
}
|
|
1063
|
+
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
// src/updateGitignore.ts
|
|
1067
|
+
async function updateGitIgnore(options) {
|
|
1068
|
+
const { root, dest, write = true } = options;
|
|
1069
|
+
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
1070
|
+
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
1071
|
+
const existing = await readFileIfExists(outputPath);
|
|
1072
|
+
const merged = mergeGitignore(existing);
|
|
1073
|
+
if (write && merged !== (existing ?? "")) {
|
|
1074
|
+
await writeFile(outputPath, merged);
|
|
1075
|
+
import_logger4.default.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1076
|
+
}
|
|
1077
|
+
return merged;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1169
1080
|
// src/index.ts
|
|
1170
1081
|
async function initConfig(options) {
|
|
1171
1082
|
const { root = import_node_process.default.cwd(), command } = options;
|
|
@@ -1181,10 +1092,8 @@ async function initConfig(options) {
|
|
|
1181
1092
|
}
|
|
1182
1093
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1183
1094
|
0 && (module.exports = {
|
|
1184
|
-
TemplateName,
|
|
1185
1095
|
createOrUpdatePackageJson,
|
|
1186
1096
|
createOrUpdateProjectConfig,
|
|
1187
|
-
createProject,
|
|
1188
1097
|
initConfig,
|
|
1189
1098
|
initTsDtsFile,
|
|
1190
1099
|
initTsJsonFiles,
|
package/dist/index.d.cts
CHANGED
|
@@ -111,17 +111,6 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
111
111
|
};
|
|
112
112
|
}>;
|
|
113
113
|
|
|
114
|
-
declare enum TemplateName {
|
|
115
|
-
default = "default",
|
|
116
|
-
wevu = "wevu",
|
|
117
|
-
tailwindcss = "tailwindcss",
|
|
118
|
-
vant = "vant",
|
|
119
|
-
tdesign = "tdesign",
|
|
120
|
-
wevuTdesign = "wevu-tdesign"
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
|
|
124
|
-
|
|
125
114
|
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJson>;
|
|
126
115
|
|
|
127
116
|
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
@@ -133,4 +122,4 @@ declare function initConfig(options: {
|
|
|
133
122
|
command?: 'weapp-vite';
|
|
134
123
|
}): Promise<Context>;
|
|
135
124
|
|
|
136
|
-
export { type Context,
|
|
125
|
+
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -111,17 +111,6 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
111
111
|
};
|
|
112
112
|
}>;
|
|
113
113
|
|
|
114
|
-
declare enum TemplateName {
|
|
115
|
-
default = "default",
|
|
116
|
-
wevu = "wevu",
|
|
117
|
-
tailwindcss = "tailwindcss",
|
|
118
|
-
vant = "vant",
|
|
119
|
-
tdesign = "tdesign",
|
|
120
|
-
wevuTdesign = "wevu-tdesign"
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
declare function createProject(targetDir?: string, templateName?: TemplateName): Promise<void>;
|
|
124
|
-
|
|
125
114
|
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJson>;
|
|
126
115
|
|
|
127
116
|
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
@@ -133,4 +122,4 @@ declare function initConfig(options: {
|
|
|
133
122
|
command?: 'weapp-vite';
|
|
134
123
|
}): Promise<Context>;
|
|
135
124
|
|
|
136
|
-
export { type Context,
|
|
125
|
+
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|