@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.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
|
|
@@ -548,9 +540,6 @@ function getDefaultTsconfigAppJson() {
|
|
|
548
540
|
paths: {
|
|
549
541
|
"@/*": [
|
|
550
542
|
"./src/*"
|
|
551
|
-
],
|
|
552
|
-
"take:@/*": [
|
|
553
|
-
"./src/*"
|
|
554
543
|
]
|
|
555
544
|
},
|
|
556
545
|
resolveJsonModule: true,
|
|
@@ -762,27 +751,12 @@ async function initTsJsonFiles(options) {
|
|
|
762
751
|
};
|
|
763
752
|
}
|
|
764
753
|
|
|
765
|
-
// src/
|
|
766
|
-
var
|
|
767
|
-
var
|
|
768
|
-
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
754
|
+
// src/packageJson.ts
|
|
755
|
+
var import_logger2 = __toESM(require("@weapp-core/logger"), 1);
|
|
756
|
+
var import_shared = require("@weapp-core/shared");
|
|
769
757
|
|
|
770
758
|
// ../../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 || {});
|
|
759
|
+
var version = "6.1.5";
|
|
786
760
|
|
|
787
761
|
// src/npm.ts
|
|
788
762
|
var import_node_https = __toESM(require("https"), 1);
|
|
@@ -826,172 +800,7 @@ async function latestVersion(packageName, prefix = "^", fetch = getLatestVersion
|
|
|
826
800
|
}
|
|
827
801
|
}
|
|
828
802
|
|
|
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
803
|
// src/packageJson.ts
|
|
993
|
-
var import_logger4 = __toESM(require("@weapp-core/logger"), 1);
|
|
994
|
-
var import_shared = require("@weapp-core/shared");
|
|
995
804
|
var FALLBACK_DEP_VERSIONS = {
|
|
996
805
|
"miniprogram-api-typings": "^4.1.0",
|
|
997
806
|
"typescript": "^5.9.2",
|
|
@@ -1031,7 +840,7 @@ async function createOrUpdatePackageJson(options) {
|
|
|
1031
840
|
let packageJson = await readJsonIfExists(packageJsonPath);
|
|
1032
841
|
if (!packageJson) {
|
|
1033
842
|
packageJson = createDefaultPackageJson();
|
|
1034
|
-
|
|
843
|
+
import_logger2.default.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${packageJsonFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u521B\u5EFA\u9ED8\u8BA4 package.json ...`);
|
|
1035
844
|
}
|
|
1036
845
|
(0, import_shared.set)(packageJson, "scripts.dev", `${command} dev`);
|
|
1037
846
|
(0, import_shared.set)(packageJson, "scripts.dev:open", `${command} dev -o`);
|
|
@@ -1053,17 +862,17 @@ async function createOrUpdatePackageJson(options) {
|
|
|
1053
862
|
ctx.packageJson.value = packageJson;
|
|
1054
863
|
if (write) {
|
|
1055
864
|
await writeJsonFile(outputPath, packageJson);
|
|
1056
|
-
|
|
865
|
+
import_logger2.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1057
866
|
}
|
|
1058
867
|
return packageJson;
|
|
1059
868
|
} catch (error) {
|
|
1060
|
-
|
|
869
|
+
import_logger2.default.error(`\u26A0\uFE0F \u8BBE\u7F6E ${packageJsonFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1061
870
|
throw error;
|
|
1062
871
|
}
|
|
1063
872
|
}
|
|
1064
873
|
|
|
1065
874
|
// src/projectConfig.ts
|
|
1066
|
-
var
|
|
875
|
+
var import_logger3 = __toESM(require("@weapp-core/logger"), 1);
|
|
1067
876
|
var import_shared2 = require("@weapp-core/shared");
|
|
1068
877
|
function applyProjectConfigDefaults(projectConfig) {
|
|
1069
878
|
(0, import_shared2.set)(projectConfig, "miniprogramRoot", "dist/");
|
|
@@ -1146,7 +955,7 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1146
955
|
applyProjectConfigDefaults(projectConfig);
|
|
1147
956
|
} else {
|
|
1148
957
|
projectConfig = createDefaultProjectConfig();
|
|
1149
|
-
|
|
958
|
+
import_logger3.default.info(`\u2728 \u6CA1\u6709\u627E\u5230 ${projectConfigFilename} \u6587\u4EF6\uFF0C\u6B63\u5728\u4F7F\u7528\u9ED8\u8BA4\u6A21\u677F\u521B\u5EFA...`);
|
|
1150
959
|
}
|
|
1151
960
|
cb?.(
|
|
1152
961
|
(...args) => {
|
|
@@ -1157,15 +966,114 @@ async function createOrUpdateProjectConfig(options) {
|
|
|
1157
966
|
ctx.projectConfig.value = projectConfig;
|
|
1158
967
|
if (write) {
|
|
1159
968
|
await writeJsonFile(outputPath, projectConfig);
|
|
1160
|
-
|
|
969
|
+
import_logger3.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1161
970
|
}
|
|
1162
971
|
return projectConfig;
|
|
1163
972
|
} catch (error) {
|
|
1164
|
-
|
|
973
|
+
import_logger3.default.error(`\u26A0\uFE0F \u8BBE\u7F6E ${projectConfigFilename} \u914D\u7F6E\u6587\u4EF6\u5931\u8D25`, error);
|
|
1165
974
|
throw error;
|
|
1166
975
|
}
|
|
1167
976
|
}
|
|
1168
977
|
|
|
978
|
+
// src/updateGitignore.ts
|
|
979
|
+
var import_logger4 = __toESM(require("@weapp-core/logger"), 1);
|
|
980
|
+
|
|
981
|
+
// src/gitignore.ts
|
|
982
|
+
var DEFAULT_GITIGNORE = `# dependencies
|
|
983
|
+
node_modules
|
|
984
|
+
.pnp
|
|
985
|
+
.pnp.js
|
|
986
|
+
|
|
987
|
+
# testing
|
|
988
|
+
coverage
|
|
989
|
+
|
|
990
|
+
# next.js
|
|
991
|
+
.next/
|
|
992
|
+
out/
|
|
993
|
+
build
|
|
994
|
+
|
|
995
|
+
# misc
|
|
996
|
+
.DS_Store
|
|
997
|
+
*.pem
|
|
998
|
+
|
|
999
|
+
# debug
|
|
1000
|
+
npm-debug.log*
|
|
1001
|
+
yarn-debug.log*
|
|
1002
|
+
yarn-error.log*
|
|
1003
|
+
.pnpm-debug.log*
|
|
1004
|
+
|
|
1005
|
+
# local env files
|
|
1006
|
+
.env.local
|
|
1007
|
+
.env.development.local
|
|
1008
|
+
.env.test.local
|
|
1009
|
+
.env.production.local
|
|
1010
|
+
|
|
1011
|
+
# turbo
|
|
1012
|
+
.turbo
|
|
1013
|
+
|
|
1014
|
+
dist
|
|
1015
|
+
dist-plugin
|
|
1016
|
+
dist-web
|
|
1017
|
+
vite.config.ts.timestamp-*.mjs`;
|
|
1018
|
+
function normalizeLineEndings(value) {
|
|
1019
|
+
return value.replace(/\r\n/g, "\n");
|
|
1020
|
+
}
|
|
1021
|
+
function trimTrailingBlankLines(lines) {
|
|
1022
|
+
let end = lines.length;
|
|
1023
|
+
while (end > 0 && lines[end - 1] === "") {
|
|
1024
|
+
end -= 1;
|
|
1025
|
+
}
|
|
1026
|
+
return lines.slice(0, end);
|
|
1027
|
+
}
|
|
1028
|
+
function ensureTrailingNewline(value) {
|
|
1029
|
+
return value.endsWith("\n") ? value : `${value}
|
|
1030
|
+
`;
|
|
1031
|
+
}
|
|
1032
|
+
function mergeGitignore(existing) {
|
|
1033
|
+
const normalizedExisting = normalizeLineEndings(existing ?? "");
|
|
1034
|
+
const existingLines = normalizedExisting.length ? normalizedExisting.split("\n") : [];
|
|
1035
|
+
const merged = [...existingLines];
|
|
1036
|
+
while (merged.length > 0 && merged[merged.length - 1] === "") {
|
|
1037
|
+
merged.pop();
|
|
1038
|
+
}
|
|
1039
|
+
const seen = new Set(merged);
|
|
1040
|
+
let appendedNonBlank = false;
|
|
1041
|
+
for (const line of DEFAULT_GITIGNORE.split("\n")) {
|
|
1042
|
+
const isBlank = line.length === 0;
|
|
1043
|
+
if (isBlank) {
|
|
1044
|
+
if (merged.length === 0 || merged[merged.length - 1] === "") {
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
merged.push("");
|
|
1048
|
+
continue;
|
|
1049
|
+
}
|
|
1050
|
+
if (seen.has(line)) {
|
|
1051
|
+
continue;
|
|
1052
|
+
}
|
|
1053
|
+
if (!appendedNonBlank && merged.length > 0 && merged[merged.length - 1] !== "") {
|
|
1054
|
+
merged.push("");
|
|
1055
|
+
}
|
|
1056
|
+
merged.push(line);
|
|
1057
|
+
seen.add(line);
|
|
1058
|
+
appendedNonBlank = true;
|
|
1059
|
+
}
|
|
1060
|
+
return ensureTrailingNewline(trimTrailingBlankLines(merged).join("\n"));
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// src/updateGitignore.ts
|
|
1064
|
+
async function updateGitIgnore(options) {
|
|
1065
|
+
const { root, dest, write = true } = options;
|
|
1066
|
+
const gitignorePath = posix.resolve(root, ".gitignore");
|
|
1067
|
+
const outputPath = resolveOutputPath(root, dest, gitignorePath);
|
|
1068
|
+
const existing = await readFileIfExists(outputPath);
|
|
1069
|
+
const merged = mergeGitignore(existing);
|
|
1070
|
+
if (write && merged !== (existing ?? "")) {
|
|
1071
|
+
await writeFile(outputPath, merged);
|
|
1072
|
+
import_logger4.default.log(`\u2728 \u66F4\u65B0 ${posix.relative(root, outputPath)} \u6210\u529F!`);
|
|
1073
|
+
}
|
|
1074
|
+
return merged;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1169
1077
|
// src/index.ts
|
|
1170
1078
|
async function initConfig(options) {
|
|
1171
1079
|
const { root = import_node_process.default.cwd(), command } = options;
|
|
@@ -1181,10 +1089,8 @@ async function initConfig(options) {
|
|
|
1181
1089
|
}
|
|
1182
1090
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1183
1091
|
0 && (module.exports = {
|
|
1184
|
-
TemplateName,
|
|
1185
1092
|
createOrUpdatePackageJson,
|
|
1186
1093
|
createOrUpdateProjectConfig,
|
|
1187
|
-
createProject,
|
|
1188
1094
|
initConfig,
|
|
1189
1095
|
initTsDtsFile,
|
|
1190
1096
|
initTsJsonFiles,
|
package/dist/index.d.cts
CHANGED
|
@@ -65,7 +65,6 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
65
65
|
baseUrl: string;
|
|
66
66
|
paths: {
|
|
67
67
|
'@/*': string[];
|
|
68
|
-
'take:@/*': string[];
|
|
69
68
|
};
|
|
70
69
|
resolveJsonModule: boolean;
|
|
71
70
|
types: string[];
|
|
@@ -111,17 +110,6 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
111
110
|
};
|
|
112
111
|
}>;
|
|
113
112
|
|
|
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
113
|
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJson>;
|
|
126
114
|
|
|
127
115
|
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
@@ -133,4 +121,4 @@ declare function initConfig(options: {
|
|
|
133
121
|
command?: 'weapp-vite';
|
|
134
122
|
}): Promise<Context>;
|
|
135
123
|
|
|
136
|
-
export { type Context,
|
|
124
|
+
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,7 +65,6 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
65
65
|
baseUrl: string;
|
|
66
66
|
paths: {
|
|
67
67
|
'@/*': string[];
|
|
68
|
-
'take:@/*': string[];
|
|
69
68
|
};
|
|
70
69
|
resolveJsonModule: boolean;
|
|
71
70
|
types: string[];
|
|
@@ -111,17 +110,6 @@ declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
|
|
|
111
110
|
};
|
|
112
111
|
}>;
|
|
113
112
|
|
|
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
113
|
declare function createOrUpdatePackageJson(options: UpdatePackageJsonOptions): Promise<PackageJson>;
|
|
126
114
|
|
|
127
115
|
declare function createOrUpdateProjectConfig(options: UpdateProjectConfigOptions): Promise<ProjectConfig>;
|
|
@@ -133,4 +121,4 @@ declare function initConfig(options: {
|
|
|
133
121
|
command?: 'weapp-vite';
|
|
134
122
|
}): Promise<Context>;
|
|
135
123
|
|
|
136
|
-
export { type Context,
|
|
124
|
+
export { type Context, createOrUpdatePackageJson, createOrUpdateProjectConfig, initConfig, initTsDtsFile, initTsJsonFiles, initViteConfigFile, resetContext };
|