@cocreate/cli 1.28.4 → 1.29.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/.github/FUNDING.yml +3 -3
- package/.github/workflows/automated.yml +55 -55
- package/CHANGELOG.md +20 -0
- package/CONTRIBUTING.md +96 -96
- package/CoCreate.config.js +26 -26
- package/LICENSE +21 -21
- package/README.md +76 -76
- package/docs/index.html +242 -67
- package/package.json +1 -1
- package/release.config.js +21 -21
- package/repositories.js +475 -475
- package/src/addMeta.js +74 -74
- package/src/coc.js +80 -80
- package/src/commands/bump.js +85 -85
- package/src/commands/clone.js +2 -2
- package/src/commands/fs/automated.js +141 -141
- package/src/commands/fs/bump.js +74 -74
- package/src/commands/fs/config.js +78 -78
- package/src/commands/fs/contribution.js +136 -136
- package/src/commands/fs/gitignore.js +40 -40
- package/src/commands/fs/icon-extract.js +31 -31
- package/src/commands/fs/manual.js +91 -91
- package/src/commands/fs/package.js +39 -39
- package/src/commands/fs/readme.js +138 -138
- package/src/commands/fs/remove.js +28 -28
- package/src/commands/fs/replace.js +42 -42
- package/src/commands/fs/webpack.js +191 -191
- package/src/commands/git/gitConfig.js +70 -70
- package/src/commands/gitConfig.js +72 -72
- package/src/commands/install.js +24 -24
- package/src/commands/link.js +107 -107
- package/src/commands/nginx.js +25 -25
- package/src/commands/other/add.js +63 -63
- package/src/commands/other/config.sh +4 -4
- package/src/commands/other/nginxConfigManager.js +137 -137
- package/src/commands/other/nodeCertManager.js +147 -147
- package/src/commands/other/symlinkPwa.js +38 -38
- package/src/commands/other/test.js +43 -43
- package/src/commands/other/updateModules.js +50 -50
- package/src/commands/symlink.js +113 -111
- package/src/execute.js +66 -66
- package/src/spawn.js +9 -9
- package/webpack.config.js +84 -84
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
let cdnUrl = "https://server.cocreate.app/";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let glob = require("glob");
|
|
6
|
-
let fs = require('fs');
|
|
7
|
-
const prettier = require("prettier");
|
|
8
|
-
const path = require("path")
|
|
9
|
-
|
|
10
|
-
function globUpdater(er, files) {
|
|
11
|
-
if (er)
|
|
12
|
-
console.log(files, 'glob resolving issue')
|
|
13
|
-
else
|
|
14
|
-
files.forEach(filename => update(filename))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function update(webpackPath) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let dir = path.dirname(webpackPath);
|
|
25
|
-
|
|
26
|
-
// component name
|
|
27
|
-
let name = path.basename(dir);
|
|
28
|
-
// component entry
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
let entry;
|
|
32
|
-
|
|
33
|
-
if (fs.existsSync( path.resolve(dir, './src/index.js') ))
|
|
34
|
-
entry = "./src/index.js";
|
|
35
|
-
else
|
|
36
|
-
entry = './src/' + name + '.js';
|
|
37
|
-
|
|
38
|
-
// get component name in came case "cocreate" less
|
|
39
|
-
let componentName = toCamelCase(name);
|
|
40
|
-
if (componentName.startsWith('CoCreate'))
|
|
41
|
-
componentName = componentName.substring(8);
|
|
42
|
-
|
|
43
|
-
if (componentName === componentName.toUpperCase())
|
|
44
|
-
componentName = componentName.toLowerCase();
|
|
45
|
-
else
|
|
46
|
-
componentName = lowerCaseFirstChar(componentName)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// has template to inject script and styles on dev compile
|
|
50
|
-
let hasTemplate = false;
|
|
51
|
-
if (fs.existsSync(path.resolve(dir, './src/index.html')))
|
|
52
|
-
hasTemplate = true;
|
|
53
|
-
let fileContent = `const path = require("path");
|
|
54
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
55
|
-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
56
|
-
let isProduction = process.env.NODE_ENV === "production";
|
|
57
|
-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
58
|
-
${ hasTemplate ? "const HtmlWebpackPlugin = require('html-webpack-plugin');" : ''}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
module.exports = {
|
|
64
|
-
entry: {
|
|
65
|
-
'${name}': '${entry}'
|
|
66
|
-
},
|
|
67
|
-
output: {
|
|
68
|
-
path: path.resolve(__dirname, 'dist'),
|
|
69
|
-
filename: isProduction ? '[name].min.js' : '[name]${hasTemplate ? '[hash]': ''}.js',
|
|
70
|
-
libraryTarget: 'umd',
|
|
71
|
-
libraryExport: 'default',
|
|
72
|
-
library: ${ componentName ? `['CoCreate', '${componentName}']` : 'CoCreate'},
|
|
73
|
-
globalObject: "this",
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
plugins: [new CleanWebpackPlugin(),
|
|
78
|
-
new MiniCssExtractPlugin({
|
|
79
|
-
filename: '[name].css',
|
|
80
|
-
}),
|
|
81
|
-
${ hasTemplate ? `
|
|
82
|
-
new HtmlWebpackPlugin({
|
|
83
|
-
template: "./src/index.html"
|
|
84
|
-
})
|
|
85
|
-
` : ''}
|
|
86
|
-
],
|
|
87
|
-
// Default mode for Webpack is production.
|
|
88
|
-
// Depending on mode Webpack will apply different things
|
|
89
|
-
// on final bundle. For now we don't need production's JavaScript
|
|
90
|
-
// minifying and other thing so let's set mode to development
|
|
91
|
-
mode: isProduction ? "production" : "development",
|
|
92
|
-
module: {
|
|
93
|
-
rules: [
|
|
94
|
-
{
|
|
95
|
-
test: /\.js$/,
|
|
96
|
-
exclude: /(node_modules)/,
|
|
97
|
-
use: {
|
|
98
|
-
loader: "babel-loader",
|
|
99
|
-
options: {
|
|
100
|
-
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
test: /\.css$/i,
|
|
106
|
-
use: [
|
|
107
|
-
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
108
|
-
"file-loader",
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// add source map
|
|
116
|
-
...(isProduction ? {} : { devtool: 'eval-source-map' }),
|
|
117
|
-
|
|
118
|
-
optimization: {
|
|
119
|
-
minimize: true,
|
|
120
|
-
minimizer: [
|
|
121
|
-
new TerserPlugin({
|
|
122
|
-
extractComments: true,
|
|
123
|
-
// cache: true,
|
|
124
|
-
parallel: true,
|
|
125
|
-
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
126
|
-
terserOptions: {
|
|
127
|
-
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
128
|
-
// extractComments: 'all',
|
|
129
|
-
compress: {
|
|
130
|
-
drop_console: true,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
}),
|
|
134
|
-
],
|
|
135
|
-
splitChunks: {
|
|
136
|
-
chunks: 'all',
|
|
137
|
-
minSize: 200,
|
|
138
|
-
// maxSize: 99999,
|
|
139
|
-
//minChunks: 1,
|
|
140
|
-
${ !hasTemplate ? `
|
|
141
|
-
cacheGroups: {
|
|
142
|
-
defaultVendors: false
|
|
143
|
-
},
|
|
144
|
-
` : ''}
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
}
|
|
149
|
-
`;
|
|
150
|
-
let formated = prettier.format(fileContent, { semi: false, parser: "babel" });
|
|
151
|
-
|
|
152
|
-
if (fs.existsSync(webpackPath))
|
|
153
|
-
fs.unlinkSync(webpackPath)
|
|
154
|
-
fs.writeFileSync(webpackPath, formated)
|
|
155
|
-
// console.log(fileContent)
|
|
156
|
-
// process.exit()
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
glob("../CoCreate-components/*/webpack.config.js", globUpdater)
|
|
163
|
-
glob("../CoCreate-apps/*/webpack.config.js", globUpdater)
|
|
164
|
-
glob("../CoCreate-plugins/*/webpack.config.js", globUpdater)
|
|
165
|
-
glob("../CoCreateCSS/webpack.config.js", globUpdater)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
function toCamelCase(str) {
|
|
172
|
-
let index = 0;
|
|
173
|
-
do {
|
|
174
|
-
index = str.indexOf("-", index);
|
|
175
|
-
if (index !== -1) {
|
|
176
|
-
let t = str.substring(0, index);
|
|
177
|
-
t += String.fromCharCode(str.charCodeAt(index + 1) - 32);
|
|
178
|
-
t += str.substring(index + 2);
|
|
179
|
-
str = t;
|
|
180
|
-
}
|
|
181
|
-
else break;
|
|
182
|
-
} while (true);
|
|
183
|
-
return str;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function lowerCaseFirstChar(str) {
|
|
187
|
-
return String.fromCharCode(str.charCodeAt(0) + 32) + str.substring(1);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
//
|
|
1
|
+
let cdnUrl = "https://server.cocreate.app/";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
let glob = require("glob");
|
|
6
|
+
let fs = require('fs');
|
|
7
|
+
const prettier = require("prettier");
|
|
8
|
+
const path = require("path")
|
|
9
|
+
|
|
10
|
+
function globUpdater(er, files) {
|
|
11
|
+
if (er)
|
|
12
|
+
console.log(files, 'glob resolving issue')
|
|
13
|
+
else
|
|
14
|
+
files.forEach(filename => update(filename))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function update(webpackPath) {
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
let dir = path.dirname(webpackPath);
|
|
25
|
+
|
|
26
|
+
// component name
|
|
27
|
+
let name = path.basename(dir);
|
|
28
|
+
// component entry
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
let entry;
|
|
32
|
+
|
|
33
|
+
if (fs.existsSync( path.resolve(dir, './src/index.js') ))
|
|
34
|
+
entry = "./src/index.js";
|
|
35
|
+
else
|
|
36
|
+
entry = './src/' + name + '.js';
|
|
37
|
+
|
|
38
|
+
// get component name in came case "cocreate" less
|
|
39
|
+
let componentName = toCamelCase(name);
|
|
40
|
+
if (componentName.startsWith('CoCreate'))
|
|
41
|
+
componentName = componentName.substring(8);
|
|
42
|
+
|
|
43
|
+
if (componentName === componentName.toUpperCase())
|
|
44
|
+
componentName = componentName.toLowerCase();
|
|
45
|
+
else
|
|
46
|
+
componentName = lowerCaseFirstChar(componentName)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// has template to inject script and styles on dev compile
|
|
50
|
+
let hasTemplate = false;
|
|
51
|
+
if (fs.existsSync(path.resolve(dir, './src/index.html')))
|
|
52
|
+
hasTemplate = true;
|
|
53
|
+
let fileContent = `const path = require("path");
|
|
54
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
55
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
56
|
+
let isProduction = process.env.NODE_ENV === "production";
|
|
57
|
+
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
58
|
+
${ hasTemplate ? "const HtmlWebpackPlugin = require('html-webpack-plugin');" : ''}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
entry: {
|
|
65
|
+
'${name}': '${entry}'
|
|
66
|
+
},
|
|
67
|
+
output: {
|
|
68
|
+
path: path.resolve(__dirname, 'dist'),
|
|
69
|
+
filename: isProduction ? '[name].min.js' : '[name]${hasTemplate ? '[hash]': ''}.js',
|
|
70
|
+
libraryTarget: 'umd',
|
|
71
|
+
libraryExport: 'default',
|
|
72
|
+
library: ${ componentName ? `['CoCreate', '${componentName}']` : 'CoCreate'},
|
|
73
|
+
globalObject: "this",
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
plugins: [new CleanWebpackPlugin(),
|
|
78
|
+
new MiniCssExtractPlugin({
|
|
79
|
+
filename: '[name].css',
|
|
80
|
+
}),
|
|
81
|
+
${ hasTemplate ? `
|
|
82
|
+
new HtmlWebpackPlugin({
|
|
83
|
+
template: "./src/index.html"
|
|
84
|
+
})
|
|
85
|
+
` : ''}
|
|
86
|
+
],
|
|
87
|
+
// Default mode for Webpack is production.
|
|
88
|
+
// Depending on mode Webpack will apply different things
|
|
89
|
+
// on final bundle. For now we don't need production's JavaScript
|
|
90
|
+
// minifying and other thing so let's set mode to development
|
|
91
|
+
mode: isProduction ? "production" : "development",
|
|
92
|
+
module: {
|
|
93
|
+
rules: [
|
|
94
|
+
{
|
|
95
|
+
test: /\.js$/,
|
|
96
|
+
exclude: /(node_modules)/,
|
|
97
|
+
use: {
|
|
98
|
+
loader: "babel-loader",
|
|
99
|
+
options: {
|
|
100
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
test: /\.css$/i,
|
|
106
|
+
use: [
|
|
107
|
+
{ loader: "style-loader", options: { injectType: "linkTag" } },
|
|
108
|
+
"file-loader",
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
// add source map
|
|
116
|
+
...(isProduction ? {} : { devtool: 'eval-source-map' }),
|
|
117
|
+
|
|
118
|
+
optimization: {
|
|
119
|
+
minimize: true,
|
|
120
|
+
minimizer: [
|
|
121
|
+
new TerserPlugin({
|
|
122
|
+
extractComments: true,
|
|
123
|
+
// cache: true,
|
|
124
|
+
parallel: true,
|
|
125
|
+
// sourceMap: true, // Must be set to true if using source-maps in production
|
|
126
|
+
terserOptions: {
|
|
127
|
+
// https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions
|
|
128
|
+
// extractComments: 'all',
|
|
129
|
+
compress: {
|
|
130
|
+
drop_console: true,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
}),
|
|
134
|
+
],
|
|
135
|
+
splitChunks: {
|
|
136
|
+
chunks: 'all',
|
|
137
|
+
minSize: 200,
|
|
138
|
+
// maxSize: 99999,
|
|
139
|
+
//minChunks: 1,
|
|
140
|
+
${ !hasTemplate ? `
|
|
141
|
+
cacheGroups: {
|
|
142
|
+
defaultVendors: false
|
|
143
|
+
},
|
|
144
|
+
` : ''}
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
}
|
|
149
|
+
`;
|
|
150
|
+
let formated = prettier.format(fileContent, { semi: false, parser: "babel" });
|
|
151
|
+
|
|
152
|
+
if (fs.existsSync(webpackPath))
|
|
153
|
+
fs.unlinkSync(webpackPath)
|
|
154
|
+
fs.writeFileSync(webpackPath, formated)
|
|
155
|
+
// console.log(fileContent)
|
|
156
|
+
// process.exit()
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
glob("../CoCreate-components/*/webpack.config.js", globUpdater)
|
|
163
|
+
glob("../CoCreate-apps/*/webpack.config.js", globUpdater)
|
|
164
|
+
glob("../CoCreate-plugins/*/webpack.config.js", globUpdater)
|
|
165
|
+
glob("../CoCreateCSS/webpack.config.js", globUpdater)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
function toCamelCase(str) {
|
|
172
|
+
let index = 0;
|
|
173
|
+
do {
|
|
174
|
+
index = str.indexOf("-", index);
|
|
175
|
+
if (index !== -1) {
|
|
176
|
+
let t = str.substring(0, index);
|
|
177
|
+
t += String.fromCharCode(str.charCodeAt(index + 1) - 32);
|
|
178
|
+
t += str.substring(index + 2);
|
|
179
|
+
str = t;
|
|
180
|
+
}
|
|
181
|
+
else break;
|
|
182
|
+
} while (true);
|
|
183
|
+
return str;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function lowerCaseFirstChar(str) {
|
|
187
|
+
return String.fromCharCode(str.charCodeAt(0) + 32) + str.substring(1);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
//
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
let fs = require('fs');
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
module.exports = async function linkPackages(repos, args) {
|
|
5
|
-
const failed = []
|
|
6
|
-
const prompt = require('prompt');
|
|
7
|
-
|
|
8
|
-
prompt.start();
|
|
9
|
-
|
|
10
|
-
const properties = [
|
|
11
|
-
{
|
|
12
|
-
name: 'email',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: 'name',
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: 'username',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
name: 'password',
|
|
22
|
-
hidden: true
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
prompt.get(properties, async function (err, result) {
|
|
27
|
-
if (err)
|
|
28
|
-
return [{
|
|
29
|
-
name: 'gitConfig',
|
|
30
|
-
des: err
|
|
31
|
-
}]
|
|
32
|
-
|
|
33
|
-
await updateConfig(result);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
async function updateConfig(result){
|
|
37
|
-
(async() => {
|
|
38
|
-
for (let repo of repos) {
|
|
39
|
-
await update(repo, result);
|
|
40
|
-
}
|
|
41
|
-
console.log('finished');
|
|
42
|
-
return failed
|
|
43
|
-
})();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function update(param, result) {
|
|
47
|
-
if (!param) return;
|
|
48
|
-
let { absoutePath, name } = param;
|
|
49
|
-
let fileContent = `[core]
|
|
50
|
-
repositoryformatversion = 0
|
|
51
|
-
filemode = true
|
|
52
|
-
bare = false
|
|
53
|
-
logallrefupdates = true
|
|
54
|
-
[user]
|
|
55
|
-
name = ${result.name}
|
|
56
|
-
email = ${result.email}
|
|
57
|
-
[remote "origin"]
|
|
58
|
-
url = https://${result.username}:${result.password}@github.com/CoCreate-app/${name}.git
|
|
59
|
-
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
60
|
-
[branch "master"]
|
|
61
|
-
remote = origin
|
|
62
|
-
merge = refs/heads/master
|
|
63
|
-
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
let MdPath = path.resolve(absoutePath, '.git/config');
|
|
67
|
-
if (fs.existsSync(MdPath))
|
|
68
|
-
fs.unlinkSync(MdPath);
|
|
69
|
-
fs.writeFileSync(MdPath, fileContent);
|
|
70
|
-
}
|
|
1
|
+
let fs = require('fs');
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = async function linkPackages(repos, args) {
|
|
5
|
+
const failed = []
|
|
6
|
+
const prompt = require('prompt');
|
|
7
|
+
|
|
8
|
+
prompt.start();
|
|
9
|
+
|
|
10
|
+
const properties = [
|
|
11
|
+
{
|
|
12
|
+
name: 'email',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'name',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'username',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'password',
|
|
22
|
+
hidden: true
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
prompt.get(properties, async function (err, result) {
|
|
27
|
+
if (err)
|
|
28
|
+
return [{
|
|
29
|
+
name: 'gitConfig',
|
|
30
|
+
des: err
|
|
31
|
+
}]
|
|
32
|
+
|
|
33
|
+
await updateConfig(result);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
async function updateConfig(result){
|
|
37
|
+
(async() => {
|
|
38
|
+
for (let repo of repos) {
|
|
39
|
+
await update(repo, result);
|
|
40
|
+
}
|
|
41
|
+
console.log('finished');
|
|
42
|
+
return failed
|
|
43
|
+
})();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function update(param, result) {
|
|
47
|
+
if (!param) return;
|
|
48
|
+
let { absoutePath, name } = param;
|
|
49
|
+
let fileContent = `[core]
|
|
50
|
+
repositoryformatversion = 0
|
|
51
|
+
filemode = true
|
|
52
|
+
bare = false
|
|
53
|
+
logallrefupdates = true
|
|
54
|
+
[user]
|
|
55
|
+
name = ${result.name}
|
|
56
|
+
email = ${result.email}
|
|
57
|
+
[remote "origin"]
|
|
58
|
+
url = https://${result.username}:${result.password}@github.com/CoCreate-app/${name}.git
|
|
59
|
+
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
60
|
+
[branch "master"]
|
|
61
|
+
remote = origin
|
|
62
|
+
merge = refs/heads/master
|
|
63
|
+
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
let MdPath = path.resolve(absoutePath, '.git/config');
|
|
67
|
+
if (fs.existsSync(MdPath))
|
|
68
|
+
fs.unlinkSync(MdPath);
|
|
69
|
+
fs.writeFileSync(MdPath, fileContent);
|
|
70
|
+
}
|
|
71
71
|
}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
let fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const failed = [];
|
|
4
|
-
|
|
5
|
-
module.exports = async function gitConfig(repos, args) {
|
|
6
|
-
try {
|
|
7
|
-
await getPrompts(repos);
|
|
8
|
-
}
|
|
9
|
-
catch (err) {
|
|
10
|
-
failed.push({ name: 'GENERAL', des: err.message });
|
|
11
|
-
console.error(err.red);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
async function getPrompts(repos){
|
|
16
|
-
const prompt = require('prompt');
|
|
17
|
-
|
|
18
|
-
prompt.start();
|
|
19
|
-
|
|
20
|
-
const properties = [
|
|
21
|
-
{
|
|
22
|
-
name: 'email',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'name',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'username',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'password',
|
|
32
|
-
hidden: true
|
|
33
|
-
}
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
prompt.get(properties, async function (err, result) {
|
|
37
|
-
if (err) { return console.error(err); }
|
|
38
|
-
await updateConfig(repos, result);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function updateConfig(repos, result){
|
|
44
|
-
for (let meta of repos) {
|
|
45
|
-
if (!meta) return;
|
|
46
|
-
let fileContent = `[core]
|
|
47
|
-
repositoryformatversion = 0
|
|
48
|
-
filemode = true
|
|
49
|
-
bare = false
|
|
50
|
-
logallrefupdates = true
|
|
51
|
-
[user]
|
|
52
|
-
name = ${result.name}
|
|
53
|
-
email = ${result.email}
|
|
54
|
-
[remote "origin"]
|
|
55
|
-
url = https://${result.username}:${result.password}@${meta.repo}
|
|
56
|
-
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
57
|
-
[branch "master"]
|
|
58
|
-
remote = origin
|
|
59
|
-
merge = refs/heads/master
|
|
60
|
-
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
let MdPath = path.resolve(meta.path, '.git/config');
|
|
64
|
-
if (fs.existsSync(MdPath))
|
|
65
|
-
fs.unlinkSync(MdPath);
|
|
66
|
-
fs.writeFileSync(MdPath, fileContent);
|
|
67
|
-
console.log('configured: ', meta.repo);
|
|
68
|
-
}
|
|
69
|
-
console.log('finished');
|
|
70
|
-
return failed
|
|
71
|
-
|
|
72
|
-
}
|
|
1
|
+
let fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const failed = [];
|
|
4
|
+
|
|
5
|
+
module.exports = async function gitConfig(repos, args) {
|
|
6
|
+
try {
|
|
7
|
+
await getPrompts(repos);
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
failed.push({ name: 'GENERAL', des: err.message });
|
|
11
|
+
console.error(err.red);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function getPrompts(repos){
|
|
16
|
+
const prompt = require('prompt');
|
|
17
|
+
|
|
18
|
+
prompt.start();
|
|
19
|
+
|
|
20
|
+
const properties = [
|
|
21
|
+
{
|
|
22
|
+
name: 'email',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'name',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'username',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'password',
|
|
32
|
+
hidden: true
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
prompt.get(properties, async function (err, result) {
|
|
37
|
+
if (err) { return console.error(err); }
|
|
38
|
+
await updateConfig(repos, result);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function updateConfig(repos, result){
|
|
44
|
+
for (let meta of repos) {
|
|
45
|
+
if (!meta) return;
|
|
46
|
+
let fileContent = `[core]
|
|
47
|
+
repositoryformatversion = 0
|
|
48
|
+
filemode = true
|
|
49
|
+
bare = false
|
|
50
|
+
logallrefupdates = true
|
|
51
|
+
[user]
|
|
52
|
+
name = ${result.name}
|
|
53
|
+
email = ${result.email}
|
|
54
|
+
[remote "origin"]
|
|
55
|
+
url = https://${result.username}:${result.password}@${meta.repo}
|
|
56
|
+
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
57
|
+
[branch "master"]
|
|
58
|
+
remote = origin
|
|
59
|
+
merge = refs/heads/master
|
|
60
|
+
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
let MdPath = path.resolve(meta.path, '.git/config');
|
|
64
|
+
if (fs.existsSync(MdPath))
|
|
65
|
+
fs.unlinkSync(MdPath);
|
|
66
|
+
fs.writeFileSync(MdPath, fileContent);
|
|
67
|
+
console.log('configured: ', meta.repo);
|
|
68
|
+
}
|
|
69
|
+
console.log('finished');
|
|
70
|
+
return failed
|
|
71
|
+
|
|
72
|
+
}
|