小程序appjson 模版生成
This commit is contained in:
parent
430dace767
commit
eafd734e1a
|
|
@ -81,6 +81,8 @@ async function create(dirName, env) {
|
||||||
});
|
});
|
||||||
// 获取tsconfig.json内容
|
// 获取tsconfig.json内容
|
||||||
const tsconfigJson = (0, template_1.tsConfigJsonContent)();
|
const tsconfigJson = (0, template_1.tsConfigJsonContent)();
|
||||||
|
// 获取小程序项目app.json内容
|
||||||
|
const appJsonWithWeChatMp = (0, template_1.appJsonContentWithWeChatMp)(isDev);
|
||||||
// 获取小程序项目project.config.json内容
|
// 获取小程序项目project.config.json内容
|
||||||
const projectConfigWithWeChatMp = (0, template_1.projectConfigContentWithWeChatMp)(config_1.USER_CONFIG_FILE_NAME, 'wechatMp', miniVersion);
|
const projectConfigWithWeChatMp = (0, template_1.projectConfigContentWithWeChatMp)(config_1.USER_CONFIG_FILE_NAME, 'wechatMp', miniVersion);
|
||||||
// 获取小程序项目oak.config.json内容
|
// 获取小程序项目oak.config.json内容
|
||||||
|
|
@ -95,6 +97,7 @@ async function create(dirName, env) {
|
||||||
const webRootPath = `${rootPath}/web`;
|
const webRootPath = `${rootPath}/web`;
|
||||||
// 小程序项目根路径
|
// 小程序项目根路径
|
||||||
const weChatMpRootPath = `${rootPath}/wechatMp`;
|
const weChatMpRootPath = `${rootPath}/wechatMp`;
|
||||||
|
const appJsonPathWithWeChatMp = `${weChatMpRootPath}/src/app.json`;
|
||||||
// 小程序项目project.config.json路径
|
// 小程序项目project.config.json路径
|
||||||
const projectConfigPathWithWeChatMp = `${weChatMpRootPath}/src/project.config.json`;
|
const projectConfigPathWithWeChatMp = `${weChatMpRootPath}/src/project.config.json`;
|
||||||
// 小程序项目project.config.json路径
|
// 小程序项目project.config.json路径
|
||||||
|
|
@ -114,6 +117,8 @@ async function create(dirName, env) {
|
||||||
(0, file_handle_1.copyFolder)(currentPath, rootPath);
|
(0, file_handle_1.copyFolder)(currentPath, rootPath);
|
||||||
// 创建小程序项目project.config.json
|
// 创建小程序项目project.config.json
|
||||||
(0, file_handle_1.checkFileExistsAndCreate)(projectConfigPathWithWeChatMp, projectConfigWithWeChatMp, enum_1.checkFileExistsAndCreateType.FILE);
|
(0, file_handle_1.checkFileExistsAndCreate)(projectConfigPathWithWeChatMp, projectConfigWithWeChatMp, enum_1.checkFileExistsAndCreateType.FILE);
|
||||||
|
// 创建小程序项目app.json
|
||||||
|
(0, file_handle_1.checkFileExistsAndCreate)(appJsonPathWithWeChatMp, appJsonWithWeChatMp, enum_1.checkFileExistsAndCreateType.FILE);
|
||||||
// 创建小程序项目oak.config.json
|
// 创建小程序项目oak.config.json
|
||||||
(0, file_handle_1.checkFileExistsAndCreate)(oakConfigPathWithWeChatMp, oakConfigWithWeChatMp, enum_1.checkFileExistsAndCreateType.FILE);
|
(0, file_handle_1.checkFileExistsAndCreate)(oakConfigPathWithWeChatMp, oakConfigWithWeChatMp, enum_1.checkFileExistsAndCreateType.FILE);
|
||||||
if (!shelljs_1.default.which('npm')) {
|
if (!shelljs_1.default.which('npm')) {
|
||||||
|
|
@ -124,9 +129,6 @@ async function create(dirName, env) {
|
||||||
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`Dependencies are now being installed`)}`);
|
(0, tip_style_1.Success)(`${(0, tip_style_1.success)(`Dependencies are now being installed`)}`);
|
||||||
shelljs_1.default.cd(dirName).exec('npm install');
|
shelljs_1.default.cd(dirName).exec('npm install');
|
||||||
// checkFileExistsAndCreate(weChatMpRootPath + '/src/styles');
|
// checkFileExistsAndCreate(weChatMpRootPath + '/src/styles');
|
||||||
// //const data = readFile(
|
|
||||||
// // `${rootPath}/node_modules/oak-frontend-boilerplate/src/platforms/wechatMp/styles/base.less`
|
|
||||||
// //);
|
|
||||||
// const data = readFile(
|
// const data = readFile(
|
||||||
// `${rootPath}/node_modules/oak-general-business/src/platforms/wechatMp/styles/base.less`
|
// `${rootPath}/node_modules/oak-general-business/src/platforms/wechatMp/styles/base.less`
|
||||||
// );
|
// );
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,5 @@ import { PackageJsonInput } from './interface';
|
||||||
export declare function packageJsonContent({ name, version, description, cliversion, cliname, isDev, }: PackageJsonInput): string;
|
export declare function packageJsonContent({ name, version, description, cliversion, cliname, isDev, }: PackageJsonInput): string;
|
||||||
export declare function tsConfigJsonContent(): string;
|
export declare function tsConfigJsonContent(): string;
|
||||||
export declare function projectConfigContentWithWeChatMp(oakConfigName: string, projectname: string, miniVersion: string): string;
|
export declare function projectConfigContentWithWeChatMp(oakConfigName: string, projectname: string, miniVersion: string): string;
|
||||||
|
export declare function appJsonContentWithWeChatMp(isDev: boolean): string;
|
||||||
export declare function oakConfigContentWithWeChatMp(): string;
|
export declare function oakConfigContentWithWeChatMp(): string;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.oakConfigContentWithWeChatMp = exports.projectConfigContentWithWeChatMp = exports.tsConfigJsonContent = exports.packageJsonContent = void 0;
|
exports.oakConfigContentWithWeChatMp = exports.appJsonContentWithWeChatMp = exports.projectConfigContentWithWeChatMp = exports.tsConfigJsonContent = exports.packageJsonContent = void 0;
|
||||||
function packageJsonContent({ name, version, description, cliversion, cliname, isDev, }) {
|
function packageJsonContent({ name, version, description, cliversion, cliname, isDev, }) {
|
||||||
let oakPackageStr;
|
let oakPackageStr;
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
|
|
@ -193,6 +193,29 @@ function projectConfigContentWithWeChatMp(oakConfigName, projectname, miniVersio
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
exports.projectConfigContentWithWeChatMp = projectConfigContentWithWeChatMp;
|
exports.projectConfigContentWithWeChatMp = projectConfigContentWithWeChatMp;
|
||||||
|
function appJsonContentWithWeChatMp(isDev) {
|
||||||
|
const pages = [];
|
||||||
|
if (isDev) {
|
||||||
|
pages.push('oak#pages/address/list/index');
|
||||||
|
pages.push('oak#pages/address/upsert/index');
|
||||||
|
pages.push('oak#pages/pickers/area/index');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pages.push('pages/index/index');
|
||||||
|
}
|
||||||
|
return `{
|
||||||
|
"pages":${JSON.stringify(pages, null, 4)},
|
||||||
|
"window":{
|
||||||
|
"backgroundTextStyle":"light",
|
||||||
|
"navigationBarBackgroundColor": "#fff",
|
||||||
|
"navigationBarTitleText": "Weixin",
|
||||||
|
"navigationBarTextStyle":"black"
|
||||||
|
},
|
||||||
|
"style": "v2",
|
||||||
|
"sitemapLocation": "sitemap.json"
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
exports.appJsonContentWithWeChatMp = appJsonContentWithWeChatMp;
|
||||||
function oakConfigContentWithWeChatMp() {
|
function oakConfigContentWithWeChatMp() {
|
||||||
return `{
|
return `{
|
||||||
"theme": {
|
"theme": {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import {
|
||||||
import {
|
import {
|
||||||
packageJsonContent,
|
packageJsonContent,
|
||||||
tsConfigJsonContent,
|
tsConfigJsonContent,
|
||||||
|
appJsonContentWithWeChatMp,
|
||||||
projectConfigContentWithWeChatMp,
|
projectConfigContentWithWeChatMp,
|
||||||
oakConfigContentWithWeChatMp,
|
oakConfigContentWithWeChatMp,
|
||||||
} from './template';
|
} from './template';
|
||||||
|
|
@ -118,6 +119,8 @@ export default async function create(dirName: string, env: string) {
|
||||||
// 获取tsconfig.json内容
|
// 获取tsconfig.json内容
|
||||||
const tsconfigJson = tsConfigJsonContent();
|
const tsconfigJson = tsConfigJsonContent();
|
||||||
|
|
||||||
|
// 获取小程序项目app.json内容
|
||||||
|
const appJsonWithWeChatMp = appJsonContentWithWeChatMp(isDev);
|
||||||
// 获取小程序项目project.config.json内容
|
// 获取小程序项目project.config.json内容
|
||||||
const projectConfigWithWeChatMp = projectConfigContentWithWeChatMp(
|
const projectConfigWithWeChatMp = projectConfigContentWithWeChatMp(
|
||||||
USER_CONFIG_FILE_NAME,
|
USER_CONFIG_FILE_NAME,
|
||||||
|
|
@ -137,6 +140,8 @@ export default async function create(dirName: string, env: string) {
|
||||||
// 小程序项目根路径
|
// 小程序项目根路径
|
||||||
const weChatMpRootPath = `${rootPath}/wechatMp`;
|
const weChatMpRootPath = `${rootPath}/wechatMp`;
|
||||||
|
|
||||||
|
const appJsonPathWithWeChatMp = `${weChatMpRootPath}/src/app.json`;
|
||||||
|
|
||||||
// 小程序项目project.config.json路径
|
// 小程序项目project.config.json路径
|
||||||
const projectConfigPathWithWeChatMp = `${weChatMpRootPath}/src/project.config.json`;
|
const projectConfigPathWithWeChatMp = `${weChatMpRootPath}/src/project.config.json`;
|
||||||
// 小程序项目project.config.json路径
|
// 小程序项目project.config.json路径
|
||||||
|
|
@ -168,6 +173,12 @@ export default async function create(dirName: string, env: string) {
|
||||||
projectConfigWithWeChatMp,
|
projectConfigWithWeChatMp,
|
||||||
checkFileExistsAndCreateType.FILE
|
checkFileExistsAndCreateType.FILE
|
||||||
);
|
);
|
||||||
|
// 创建小程序项目app.json
|
||||||
|
checkFileExistsAndCreate(
|
||||||
|
appJsonPathWithWeChatMp,
|
||||||
|
appJsonWithWeChatMp,
|
||||||
|
checkFileExistsAndCreateType.FILE
|
||||||
|
);
|
||||||
// 创建小程序项目oak.config.json
|
// 创建小程序项目oak.config.json
|
||||||
checkFileExistsAndCreate(
|
checkFileExistsAndCreate(
|
||||||
oakConfigPathWithWeChatMp,
|
oakConfigPathWithWeChatMp,
|
||||||
|
|
@ -183,9 +194,6 @@ export default async function create(dirName: string, env: string) {
|
||||||
shell.cd(dirName).exec('npm install');
|
shell.cd(dirName).exec('npm install');
|
||||||
|
|
||||||
// checkFileExistsAndCreate(weChatMpRootPath + '/src/styles');
|
// checkFileExistsAndCreate(weChatMpRootPath + '/src/styles');
|
||||||
// //const data = readFile(
|
|
||||||
// // `${rootPath}/node_modules/oak-frontend-boilerplate/src/platforms/wechatMp/styles/base.less`
|
|
||||||
// //);
|
|
||||||
// const data = readFile(
|
// const data = readFile(
|
||||||
// `${rootPath}/node_modules/oak-general-business/src/platforms/wechatMp/styles/base.less`
|
// `${rootPath}/node_modules/oak-general-business/src/platforms/wechatMp/styles/base.less`
|
||||||
// );
|
// );
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,29 @@ export function projectConfigContentWithWeChatMp(
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function appJsonContentWithWeChatMp(isDev: boolean) {
|
||||||
|
const pages = [];
|
||||||
|
if (isDev) {
|
||||||
|
pages.push('oak#pages/address/list/index');
|
||||||
|
pages.push('oak#pages/address/upsert/index');
|
||||||
|
pages.push('oak#pages/pickers/area/index');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pages.push('pages/index/index');
|
||||||
|
}
|
||||||
|
return `{
|
||||||
|
"pages":${JSON.stringify(pages, null, 4)},
|
||||||
|
"window":{
|
||||||
|
"backgroundTextStyle":"light",
|
||||||
|
"navigationBarBackgroundColor": "#fff",
|
||||||
|
"navigationBarTitleText": "Weixin",
|
||||||
|
"navigationBarTextStyle":"black"
|
||||||
|
},
|
||||||
|
"style": "v2",
|
||||||
|
"sitemapLocation": "sitemap.json"
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function oakConfigContentWithWeChatMp() {
|
export function oakConfigContentWithWeChatMp() {
|
||||||
return `{
|
return `{
|
||||||
"theme": {
|
"theme": {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"pages":[
|
|
||||||
"pages/index/index",
|
|
||||||
"oak#pages/address/list/index",
|
|
||||||
"oak#pages/address/upsert/index"
|
|
||||||
],
|
|
||||||
"window":{
|
|
||||||
"backgroundTextStyle":"light",
|
|
||||||
"navigationBarBackgroundColor": "#fff",
|
|
||||||
"navigationBarTitleText": "Weixin",
|
|
||||||
"navigationBarTextStyle":"black"
|
|
||||||
},
|
|
||||||
"style": "v2",
|
|
||||||
"sitemapLocation": "sitemap.json"
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue