Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dfzx_mb_04
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
dfzx_mb_04
Commits
82a725da
Commit
82a725da
authored
Oct 23, 2020
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 编译打包
parent
9ca3e8b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
66 deletions
+54
-66
angular.json
angular.json
+1
-1
publish.js
bin/publish.js
+53
-65
No files found.
angular.json
View file @
82a725da
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
"build"
:
{
"build"
:
{
"builder"
:
"@angular-devkit/build-angular:browser"
,
"builder"
:
"@angular-devkit/build-angular:browser"
,
"options"
:
{
"options"
:
{
"outputPath"
:
"dist"
,
"outputPath"
:
"dist
/ng-template-generator
"
,
"index"
:
"src/index.html"
,
"index"
:
"src/index.html"
,
"main"
:
"src/main.ts"
,
"main"
:
"src/main.ts"
,
"polyfills"
:
"src/polyfills.ts"
,
"polyfills"
:
"src/polyfills.ts"
,
...
...
bin/publish.js
View file @
82a725da
/****
/* eslint-disable */
/** **
* 批量编译打包模板工具
* 批量编译打包模板工具
* 运行 npm run publish T_01 命令来打包T_01模板
* 运行 npm run publish T_01 命令来打包T_01模板
* 运行 npm run publish T_01,T_02,T_03,T_04 命令来分别打包 T_01,T_02,T_03,T_04 这四个模板,注意逗号要用英文的
* 运行 npm run publish T_01,T_02,T_03,T_04 命令来分别打包 T_01,T_02,T_03,T_04 这四个模板,注意逗号要用英文的
...
@@ -11,47 +12,42 @@ const fs = require("fs");
...
@@ -11,47 +12,42 @@ const fs = require("fs");
const
os
=
require
(
'
os
'
);
const
os
=
require
(
'
os
'
);
const
compressing
=
require
(
"
compressing
"
);
const
compressing
=
require
(
"
compressing
"
);
//Linux系统上'Linux'
//
Linux系统上'Linux'
//
macOS 系统上'Darwin'
//
macOS 系统上'Darwin'
//Windows系统上'Windows_NT'
//
Windows系统上'Windows_NT'
let
sysType
=
os
.
type
();
const
sysType
=
os
.
type
();
Date
.
prototype
.
Format
=
function
(
fmt
)
{
Date
.
prototype
.
Format
=
function
(
fmt
)
{
var
o
=
{
const
o
=
{
"
M+
"
:
this
.
getMonth
()
+
1
,
"
M+
"
:
this
.
getMonth
()
+
1
,
"
d+
"
:
this
.
getDate
(),
"
d+
"
:
this
.
getDate
(),
"
h+
"
:
this
.
getHours
(),
"
h+
"
:
this
.
getHours
(),
"
m+
"
:
this
.
getMinutes
(),
"
m+
"
:
this
.
getMinutes
(),
"
s+
"
:
this
.
getSeconds
(),
"
s+
"
:
this
.
getSeconds
(),
"
q+
"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
"
q+
"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
"
S
"
:
this
.
getMilliseconds
()
S
:
this
.
getMilliseconds
(),
};
};
if
(
/
(
y+
)
/
.
test
(
fmt
))
if
(
/
(
y+
)
/
.
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
`
${
this
.
getFullYear
()}
`
).
substr
(
4
-
RegExp
.
$1
.
length
));
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
));
for
(
const
k
in
o
)
if
(
new
RegExp
(
`(
${
k
}
)`
).
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
`00
${
o
[
k
]}
`
).
substr
((
`
${
o
[
k
]}
`
).
length
)));
for
(
var
k
in
o
)
if
(
new
RegExp
(
"
(
"
+
k
+
"
)
"
).
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
"
00
"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
return
fmt
;
return
fmt
;
}
}
;
function
clean
(
zipPath
){
function
clean
(
zipPath
)
{
if
(
fs
.
existsSync
(
zipPath
))
{
if
(
fs
.
existsSync
(
zipPath
))
{
fs
.
unlinkSync
(
zipPath
);
fs
.
unlinkSync
(
zipPath
);
}
}
}
}
const
runSpawn
=
async
function
(){
const
runSpawn
=
async
function
()
{
await
new
Promise
(((
resolve
,
reject
)
=>
{
await
new
Promise
(
function
(
resolve
,
reject
){
const
pkg
=
require
(
"
../package.json
"
);
let
pkg
=
require
(
"
../package.json
"
);
let
ls
;
let
ls
;
if
(
sysType
===
"
Windows_NT
"
)
{
if
(
sysType
===
"
Windows_NT
"
)
{
//ng build --prod --build--optimizer --base-href /ng-one/
//
ng build --prod --build--optimizer --base-href /ng-one/
ls
=
spawn
(
"
cmd.exe
"
,
[
'
/c
'
,
'
ng
'
,
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]
);
ls
=
spawn
(
"
cmd.exe
"
,
[
'
/c
'
,
'
ng
'
,
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]);
}
else
{
}
else
{
ls
=
spawn
(
"
ng
"
,
[
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]
);
ls
=
spawn
(
"
ng
"
,
[
'
build
'
,
'
--prod
'
,
'
--build--optimizer
'
,
'
--base-href
'
,
'
/template-base-href/
'
]);
}
}
ls
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
ls
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
...
@@ -65,36 +61,32 @@ const runSpawn = async function (){
...
@@ -65,36 +61,32 @@ const runSpawn = async function (){
ls
.
on
(
'
close
'
,
(
code
)
=>
{
ls
.
on
(
'
close
'
,
(
code
)
=>
{
console
.
log
(
`child process exited with code
${
code
}
`
);
console
.
log
(
`child process exited with code
${
code
}
`
);
//要压缩的目录
// 要压缩的目录
let
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
);
const
zippath
=
path
.
resolve
(
__dirname
,
"
../dist
"
,
pkg
.
name
);
//压缩包的存放目录
// 压缩包的存放目录
let
date
=
new
Date
();
const
zipdir
=
path
.
resolve
(
__dirname
,
`../publish/form.zip`
);
let
zipname
=
pkg
.
name
+
"
_
"
+
date
.
Format
(
"
yyyyMMdd hh-mm-ss
"
);
clean
(
zipdir
);
// 删除原有的包
let
zipdir
=
path
.
resolve
(
__dirname
,
"
../publish/
"
+
zipname
+
"
.zip
"
);
clean
(
zipdir
);
//删除原有的包
const
tarStream
=
new
compressing
.
zip
.
Stream
();
const
tarStream
=
new
compressing
.
zip
.
Stream
();
fs
.
readdir
(
zippath
,
function
(
err
,
files
)
{
fs
.
readdir
(
zippath
,
(
err
,
files
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
"
======文件打开异常======
"
);
console
.
log
(
"
======文件打开异常======
"
);
console
.
log
(
err
);
console
.
log
(
err
);
reject
();
reject
();
}
}
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
files
.
length
;
i
++
)
{
tarStream
.
addEntry
(
zippath
+
"
/
"
+
files
[
i
]
);
tarStream
.
addEntry
(
`
${
zippath
}
/
${
files
[
i
]}
`
);
}
}
le
t
writeStream
=
fs
.
createWriteStream
(
zipdir
);
cons
t
writeStream
=
fs
.
createWriteStream
(
zipdir
);
tarStream
.
pipe
(
writeStream
);
tarStream
.
pipe
(
writeStream
);
writeStream
.
on
(
'
close
'
,
()
=>
{
writeStream
.
on
(
'
close
'
,
()
=>
{
console
.
log
(
`模板
${
pkg
.
name
}
打包已完成!`
);
console
.
log
(
`模板
${
pkg
.
name
}
打包已完成!`
);
resolve
();
resolve
();
})
});
});
});
});
});
});
}
}));
};
// let projects = "";
// let projects = "";
// if(process.argv.length<3){
// if(process.argv.length<3){
...
@@ -103,13 +95,9 @@ const runSpawn = async function (){
...
@@ -103,13 +95,9 @@ const runSpawn = async function (){
// }
// }
// projects = process.argv[2];
// projects = process.argv[2];
let
exec
=
async
function
()
{
const
exec
=
async
function
()
{
//压缩模板
//
压缩模板
await
runSpawn
();
await
runSpawn
();
}
}
;
exec
();
exec
();
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment