提交 1a26ff4b 编写于 作者: Y yylgit

deleteExt

上级 89ba8e6b
......@@ -383,6 +383,18 @@ _.getRouterConfig = function() {
};
}
// 获取子项目的路由配置
_.getSubProjectRouter = function() {
let subProject = cml.config.get().subProject;
let subProjectMap = {};
if (subProject && subProject.length > 0) {
subProject.forEach(function(npmName) {
let npmRouterConfig = _.readsubProjectRouterConfig(cml.projectRoot, npmName);
subProjectMap[npmName] = npmRouterConfig;
})
}
return subProjectMap;
}
// 分离文件
_.splitParts = function ({
......@@ -887,7 +899,7 @@ _.lintHandleComponentUrl = function(context, cmlFilePath, comPath) {
// if (/\.cml$/.test(result.filePath) && !cmlReg.test(result.filePath)) {
// result.isCml = true;
// }
if (!_.RecordCml2Interface[result.filePath]) {
if (/\.cml$/.test(result.filePath) && !_.RecordCml2Interface[result.filePath]) {
result.isCml = true;
}
return result;
......@@ -1201,12 +1213,13 @@ _.isInline = function(filePath) {
return false;
}
// 删除cml文件的后缀 因为有了script src语法之后 .cmlType.cml的语法已经
// 删除cml文件的后缀 因为有了script src语法之后 .cmlType.cml的语法已经无法穷举,
// 处理的文件分隔符为 /
_.deleteExt = function(filePath) {
let basename = path.basename(filePath);
let dirname = path.dirname(filePath);
basename = basename.split('.')[0];
let result = path.join(dirname, basename);
let result = dirname + '/' + basename;
result = _.handleWinPath(result);
return result;
}
......@@ -159,7 +159,6 @@ describe('index.js', function () {
let result = _.splitParts({
content: cmlFileContent
});
debugger
expect(result.template.length).to.equal(1);
expect(result.script.length).to.equal(2);
expect(result.style.length).to.equal(1);
......@@ -341,7 +340,6 @@ describe('index.js', function () {
path.join(cml.projectRoot, 'index.cml'),
`../${item.key}/${item.key}`,
]
let result = _.lintHandleComponentUrl(...params);
expect(result.filePath).to.equal(path.join(__dirname, `./testlib/${item.key}/${item.key}.${item.name}`));
expect(result.isCml).to.equal(undefined);
......@@ -380,7 +378,7 @@ describe('index.js', function () {
var cmlFilePath = path.join(__dirname, 'testlib/demo-project/src/pages/page1/page1.cml');
var comrefPath = 'vant-weapp/test'
debugger
let result = _.handleComponentUrl(cml.projectRoot, cmlFilePath, comrefPath, 'wx');
expect(result.refUrl).to.equal('./../../npm/vant-weapp/test');
})
......@@ -650,11 +648,28 @@ describe('index.js', function () {
cml.utils = _;
var obj = {};
_.addNpmComponents(obj, path.join(path.join(__dirname, './testlib/demo-project/src/pages/page1/page1.cml')), 'wx', cml.projectRoot);
console.log(obj)
expect(obj).to.has.property('usingComponents');
})
it(`deleteExt`, function () {
global.cml = {};
_.setCli(true);
cml.projectRoot = path.join(__dirname, './testlib/demo-project');
cml.config = {
get() {
return {
subProject: ['cml-subproject']
}
}
}
let result = _.getSubProjectRouter();
expect(Object.keys(result).length).to.be.equal(1);
})
it(`deleteExt`, function () {
global.cml = {};
_.setCli(true);
......@@ -667,7 +682,7 @@ describe('index.js', function () {
let result3 = _.deleteExt(path3);
expect(result1).to.be.equal('/src/pages/name');
expect(result2).to.be.equal('/src/pages/name');
expect(result3).to.be.equal('name');
expect(result3).to.be.equal('./name');
})
})
// 设置静态资源的线上路径
const publicPath = '//www.static.chameleon.com/cml';
// 设置api请求前缀
const apiPrefix = 'https://api.chameleon.com';
cml.config.merge({
templateLang: 'cml',
templateType: 'html',
subProject: ['cml-subproject'],
platforms: ['web', 'weex', 'wx', 'baidu', 'alipay'],
buildInfo: {
wxAppId: '123456'
},
wx: {
dev: {
},
build: {
apiPrefix
}
},
web: {
dev: {
analysis: false,
console: false
},
build: {
analysis: false,
publicPath: `${publicPath}/web/`,
apiPrefix
}
},
weex: {
dev: {
},
build: {
publicPath: `${publicPath}/weex/`,
apiPrefix
},
custom: {
publicPath: `${publicPath}/wx/`,
apiPrefix
}
}
})
# Editor directories and files
.DS_Store
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
.vscode
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# ///////////////////////////
# dist
dist/
output/
.temp
node_modules
// 设置静态资源的线上路径
const publicPath = '//www.static.chameleon.com/cml';
// 设置api请求前缀
const apiPrefix = 'https://api.chameleon.com';
cml.config.merge({
templateLang: 'cml',
templateType: 'html',
platforms: ['web', 'weex', 'wx', 'baidu', 'alipay'],
buildInfo: {
wxAppId: '123456'
},
wx: {
dev: {
},
build: {
apiPrefix
}
},
web: {
dev: {
analysis: false,
console: false
},
build: {
analysis: false,
publicPath: `${publicPath}/web/`,
apiPrefix
}
},
weex: {
dev: {
},
build: {
publicPath: `${publicPath}/weex/`,
apiPrefix
},
custom: {
publicPath: `${publicPath}/wx/`,
apiPrefix
}
}
})
module.exports = [
{
method: ['get', 'post'],
path: '/api/getMessage',
controller: function (req, res, next) {
res.json({
total: 0,
message: [{
name: 'Hello chameleon!'
}]
});
}
}
]
<?php
$chameleon = array(
"errno"=> "0",
"errmsg"=> "",
"pageData"=> array(
"name"=>"chameleon",
"age" => 10
)
);
\ No newline at end of file
{
"name": "chameleon",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"chameleon-api": {
"version": "0.4.3",
"resolved": "https://registry.npmjs.org/chameleon-api/-/chameleon-api-0.4.3.tgz",
"integrity": "sha512-byqC9UZAlAdVT70Pl5szDRvmLW4T13Gexc0/sZiZleElmpcgkVf78ruT7T7u4ISmuTa5G3oWi680jZevfBk0pA==",
"requires": {
"chameleon-bridge": "0.1.0",
"child_process": "1.0.2",
"fetch-detector": "1.0.1",
"fetch-ie8": "1.5.0"
},
"dependencies": {
"chameleon-bridge": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/chameleon-bridge/-/chameleon-bridge-0.1.0.tgz",
"integrity": "sha512-1Qc7F4ts0zlfglGn3VnVSPg3SRge37gu5/EQ+Mz8K3vqpRgoXGPN6cRtK+4wrvqox740gml+yWsuV10GY2xB1A=="
}
}
},
"chameleon-bridge": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/chameleon-bridge/-/chameleon-bridge-0.1.2.tgz",
"integrity": "sha512-Nrah3QBWzqXw5C6oSiD/mM2vVZTaRKE58Y1d/iasQa/7vNKNGLhvc/r8FJS6k7kBAgMSJJFLuUd475x2/x5Fbg=="
},
"chameleon-runtime": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/chameleon-runtime/-/chameleon-runtime-0.1.4.tgz",
"integrity": "sha512-k1/k/b3XVZR+G+2PzdGheyL3QcH43ixGmzmuzS08Wg4H/ZC0lQ6kAieQNl3LtnrkMO0DCbfI5B+Ce36EQEp8bg==",
"requires": {
"mobx": "3.6.1"
}
},
"chameleon-scroll": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/chameleon-scroll/-/chameleon-scroll-0.0.3.tgz",
"integrity": "sha512-9ru7moY9uU3ZouE74OmZ4pP0YHRXkin+oLvfCqKaXHRhK2Cg8kdFRaofmaLJyokb0R6S4Q7h1IQAsMcFoWkmEA=="
},
"chameleon-store": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/chameleon-store/-/chameleon-store-0.0.3.tgz",
"integrity": "sha512-f6lmeDW01xnau71iXK52haomD2etmQg+gBvVFO5T84eqs9AxtXiRkYAjxl/rqu+ejFACAm1nWMfAjXldw0lUTQ==",
"requires": {
"mobx": "3.6.1",
"vuex": "3.0.1"
}
},
"chameleon-ui-builtin": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/chameleon-ui-builtin/-/chameleon-ui-builtin-0.2.0.tgz",
"integrity": "sha512-IR0vbrvd5WIU1JXimHu/G4ByP+jWXCTSOoD8XWckw+8K5w3hlDoxBa1ca//+54AGD7Y/yTx5Q+Trf/itAeC8Ww==",
"requires": {
"chameleon-scroll": "0.0.3"
}
},
"child_process": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz",
"integrity": "sha1-sffn/HPSXn/R1FWtyU4UODAYK1o="
},
"cml-ui": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/cml-ui/-/cml-ui-0.1.7.tgz",
"integrity": "sha512-oxzAHXzi4D2nxnoEk0XylAbuBwSDZhR/G43UmjePOfGnDJBNhgIMB3UnDGjIpEmJVS5S0t1pEGPNCjFrzJ+LnQ=="
},
"fetch-detector": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/fetch-detector/-/fetch-detector-1.0.1.tgz",
"integrity": "sha1-bLPq9zjCcnhi6GiA1hIUI+qkIIM="
},
"fetch-ie8": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/fetch-ie8/-/fetch-ie8-1.5.0.tgz",
"integrity": "sha1-8RQcP5bLyJN6oxsPvBp3AiD7wVs="
},
"mobx": {
"version": "3.6.1",
"resolved": "https://registry.npmjs.org/mobx/-/mobx-3.6.1.tgz",
"integrity": "sha1-rmOo8A4UhadA0Pka4val9o4wO+o="
},
"vuex": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.0.1.tgz",
"integrity": "sha512-wLoqz0B7DSZtgbWL1ShIBBCjv22GV5U+vcBFox658g6V0s4wZV9P4YjCNyoHSyIBpj1f29JBoNQIqD82cR4O3w=="
}
}
}
{
"name": "chameleon",
"version": "1.0.0",
"description": "A chameleon project",
"author": "",
"private": true,
"scripts": {},
"license": "MIT",
"dependencies": {
"chameleon-api": "0.4.3",
"chameleon-bridge": "0.1.2",
"chameleon-runtime": "0.1.4",
"chameleon-store": "0.0.3",
"chameleon-ui-builtin": "^0.2.0",
"cml-ui": "0.1.7"
}
}
<template>
<app store="{{store}}" router-config="{{routerConfig}}"></app>
</template>
<script>
import store from '../store/index.js'
import routerConfig from '../router.config.json';
class App {
data = {
store,
routerConfig
}
created(res) {
}
}
export default new App();
</script>
<style>
</style>
<script cml-type="json">
{
"wx": {
"window": {
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Chameleon",
"navigationBarTextStyle":"black"
}
},
"baidu": {
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTitleText": "Chameleon",
"navigationBarTextStyle": "black"
}
},
"alipay": {
"window": {
"defaultTitle": "Chameleon"
}
}
}
</script>
\ No newline at end of file
<template>
<view class="demo-com">
<text class="title">{{title}}</text>
<image src="{{imageSrc}}" class="logo"></image>
</view>
</template>
<script>
class DemoCom {
props = {
title: {
type: String,
default: ''
},
imageSrc: {
type: String,
default: ''
},
}
data = {
}
computed = {
}
watch = {
}
methods = {
}
beforeCreate() {
}
created() {
}
beforeMount() {
}
mounted() {
}
beforeDestroy() {
}
destroyed() {
}
}
export default new DemoCom();
</script>
<style>
.demo-com {
display: flex;
flex-direction: column;
align-items: center;
}
.title {
align-self: center;
color: #61c7fc;
font-size: 72cpx;
margin-top: 160cpx;
margin-bottom: 20cpx;
}
.logo {
width: 150cpx;
height: 150cpx;
margin-top: 100cpx;
}
</style>
<script cml-type="json">
{
"base": {
"usingComponents": {}
}
}
</script>
<template>
<page title="chameleon">
<scroller height="{{-1}}">
<view class="scroller-wrap">
<demo-com title="{{title}}" image-src="{{chameleonSrc}}"></demo-com>
</view>
</scroller>
</page>
</template>
<script>
class Index {
data = {
title: "chameleon",
chameleonSrc: require('../../assets/images/chameleon.png')
}
}
export default new Index();
</script>
<style>
.scroller-wrap {
display: flex;
flex-direction: column;
align-items: center;
}
</style>
<script cml-type="json">
{
"base": {
"usingComponents": {
"demo-com": "/components/demo-com/demo-com"
}
},
"wx": {
"navigationBarTitleText": "index",
"backgroundTextStyle": "dark",
"backgroundColor": "#E2E2E2"
},
"alipay": {
"defaultTitle": "index",
"pullRefresh": false,
"allowsBounceVertical": "YES",
"titleBarColor": "#ffffff"
},
"baidu": {
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "white",
"navigationBarTitleText": "index",
"backgroundColor": "#ffffff",
"backgroundTextStyle": "dark",
"enablePullDownRefresh": false,
"onReachBottomDistance": 50
}
}
</script>
{
"mode": "history",
"domain": "https://www.chameleon.com",
"routes":[
{
"url": "/cml/h5/index",
"path": "/pages/index/index",
"name": "首页",
"mock": "index.php"
}
]
}
\ No newline at end of file
import actions from './actions'
import getters from './getters'
import state from './state'
import mutations from './mutations'
import createStore from "chameleon-store";
export default createStore({
actions,
getters,
state,
mutations
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册