@qrvey/utils 1.2.10-4 → 1.2.10-5
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/bitbucket-pipelines.yml +1 -1
- package/package.json +1 -1
- package/publishing.js +50 -49
package/bitbucket-pipelines.yml
CHANGED
package/package.json
CHANGED
package/publishing.js
CHANGED
|
@@ -17,7 +17,6 @@ const question = util.promisify(rl.question).bind(rl);
|
|
|
17
17
|
async function execute(command) {
|
|
18
18
|
console.log(command);
|
|
19
19
|
const response = await exec(command);
|
|
20
|
-
console.log('response', response);
|
|
21
20
|
if (response.error != null) {
|
|
22
21
|
throw new Error(response.error);
|
|
23
22
|
}
|
|
@@ -61,66 +60,57 @@ async function spawning(command, sArguments) {
|
|
|
61
60
|
reject();
|
|
62
61
|
}
|
|
63
62
|
resolve();
|
|
64
|
-
|
|
65
63
|
});
|
|
66
64
|
});
|
|
67
65
|
}
|
|
68
66
|
|
|
69
|
-
async function
|
|
70
|
-
console.log('
|
|
67
|
+
async function getPackageJson(settings) {
|
|
68
|
+
console.log('==>>> Opening package.json file...');
|
|
71
69
|
const packageJson = await fs.readFileSync(settings.packagePath, 'utf8');
|
|
72
70
|
const packageObject = JSON.parse(packageJson);
|
|
73
71
|
if (packageObject != null) {
|
|
74
|
-
console.log(
|
|
72
|
+
console.log(`**** The current version is ${packageObject.version}`);
|
|
75
73
|
return packageObject.version;
|
|
76
74
|
}
|
|
77
75
|
return '';
|
|
78
76
|
}
|
|
79
77
|
|
|
78
|
+
async function getNewVersion() {
|
|
79
|
+
console.log('==>>> Checking the new version provided...');
|
|
80
|
+
let newVersion;
|
|
81
|
+
const versionIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-new-version='); });
|
|
82
|
+
if (versionIndex > -1) {
|
|
83
|
+
const versionArg = proc.argv[versionIndex].split('--np-new-version=');
|
|
84
|
+
newVersion = versionArg[1] == null || versionArg[1] === '' ? undefined : versionArg[1];
|
|
85
|
+
}
|
|
86
|
+
if (newVersion == null) {
|
|
87
|
+
newVersion = question('No version provided. Type the new version: ');
|
|
88
|
+
}
|
|
89
|
+
console.log('**** Version to publish: ' + newVersion);
|
|
90
|
+
return newVersion;
|
|
91
|
+
}
|
|
92
|
+
|
|
80
93
|
async function cleaningProject(settings) {
|
|
81
|
-
console.log('
|
|
94
|
+
console.log('==>>> Cleaning project...');
|
|
82
95
|
await execute(`rm -f ${settings.packageLockPath}`);
|
|
83
96
|
await execute(`rm -f -R ${settings.nodeModulesPath}`);
|
|
84
97
|
await execute(`rm -f -R ${settings.distPath}`);
|
|
85
98
|
}
|
|
86
99
|
|
|
87
100
|
async function buildingBundle(_settings) {
|
|
88
|
-
console.log('
|
|
101
|
+
console.log('==>>> Installing Dependencies...');
|
|
89
102
|
await execute('npm install');
|
|
90
103
|
|
|
91
|
-
console.log('
|
|
104
|
+
console.log('==>>> Generating Build...');
|
|
92
105
|
await execute('npm run build');
|
|
93
106
|
}
|
|
94
107
|
|
|
95
|
-
async function generatingDocument(settings) {
|
|
96
|
-
console.log('>>> Generating Document...');
|
|
97
|
-
await execute(`doxdox './dist/.+\\.js' --output ${settings.docsFileName} --ignore './dist/cjs/.+\\.js' --package ${settings.packagePath}`);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async function pushingChanges(settings) {
|
|
101
|
-
console.log('>>> Commiting and Pushing Docs changes...');
|
|
102
|
-
|
|
103
|
-
const gitStdout = await execute('git rev-parse --abbrev-ref HEAD');
|
|
104
|
-
console.log('gitStdout', gitStdout);
|
|
105
|
-
await execute(`git add ${settings.docsPath}`);
|
|
106
|
-
await execute(`git commit -m "📝 docs: Updated docs${settings.packageVersion !== '' ? ' for ' + settings.packageVersion : ''}"`);
|
|
107
|
-
await execute(`git push -u origin ${gitStdout}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async function revertChanges(settings) {
|
|
111
|
-
console.log('>>> Checking for modifications...');
|
|
112
|
-
console.warn(`>>> Unstaging posible changes from ${settings.docsFileName} file`);
|
|
113
|
-
await execute(`git restore --staged ${settings.docsPath}`);
|
|
114
|
-
console.warn(`>>> Discarting posible changes of ${settings.docsFileName} file`);
|
|
115
|
-
await execute(`git checkout -- ${settings.docsPath}`);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
108
|
async function startPublishingVersion(settings) {
|
|
119
109
|
await callingPublisher(settings);
|
|
120
110
|
}
|
|
121
111
|
|
|
122
112
|
async function callingPublisher(settings) {
|
|
123
|
-
console.log('
|
|
113
|
+
console.log('==>>> Calling Publisher');
|
|
124
114
|
let anyBranch = '', tag = '';
|
|
125
115
|
const anyBranchIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-any-branch='); });
|
|
126
116
|
const tagIndex = proc.argv.findIndex(function (argv) { return argv.includes('--np-tag='); });
|
|
@@ -132,49 +122,60 @@ async function callingPublisher(settings) {
|
|
|
132
122
|
const tagArg = proc.argv[tagIndex].split('--np-tag=');
|
|
133
123
|
tag = tagArg[1] == null || tagArg[1] === '' ? '' : proc.argv[tagIndex].replace('--np-tag=', '--tag=');
|
|
134
124
|
}
|
|
135
|
-
// await execute(`np ${settings.newVersion} ${anyBranch} ${tag}`);
|
|
136
125
|
await spawning(`np ${settings.newVersion}`, [anyBranch, tag]);
|
|
137
126
|
}
|
|
138
127
|
|
|
139
128
|
async function startGeneratingDocs(settings) {
|
|
140
|
-
console.log('
|
|
129
|
+
console.log('==>>> Starting the Docs generation');
|
|
141
130
|
|
|
142
131
|
await generatingDocument(settings);
|
|
143
132
|
await pushingChanges(settings);
|
|
144
133
|
}
|
|
145
134
|
|
|
146
|
-
async function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
135
|
+
async function generatingDocument(settings) {
|
|
136
|
+
console.log('==>>> Generating Document...');
|
|
137
|
+
await execute(`doxdox './dist/.+\\.js' --output ${settings.docsFileName} --ignore './dist/cjs/.+\\.js' --package ${settings.packagePath}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function pushingChanges(settings) {
|
|
141
|
+
console.log('==>>> Commiting and Pushing Docs changes...');
|
|
142
|
+
|
|
143
|
+
const gitStdout = await execute('git rev-parse --abbrev-ref HEAD');
|
|
144
|
+
console.log('gitStdout', gitStdout);
|
|
145
|
+
await execute(`git add ${settings.docsPath}`);
|
|
146
|
+
await execute(`git commit -m "📝 docs: Updated docs${settings.newVersion != null || settings.newVersion !== '' ? ' for ' + settings.newVersion : ''}"`);
|
|
147
|
+
await execute(`git push -u origin ${gitStdout.stdout}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function revertChanges(settings) {
|
|
151
|
+
console.log('>>> Checking for modifications...');
|
|
152
|
+
console.warn(`>>> Unstaging posible changes from ${settings.docsFileName} and ${settings.packageFileName} file`);
|
|
153
|
+
await execute(`git restore --staged ${settings.docsPath} ${settings.packagePath}`);
|
|
154
|
+
console.warn(`>>> Discarting posible changes of ${settings.docsFileName} and ${settings.packageFileName} file`);
|
|
155
|
+
await execute(`git checkout -- ${settings.docsPath} ${settings.packagePath}`);
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
async function init() {
|
|
160
159
|
let settings = {
|
|
160
|
+
currentVersion: '',
|
|
161
161
|
distPath: './dist',
|
|
162
162
|
docsPath: './README.md',
|
|
163
163
|
docsFileName: 'README.md',
|
|
164
164
|
newVersion: undefined,
|
|
165
165
|
nodeModulesPath: './node_modules',
|
|
166
|
+
packageFileName: 'package.json',
|
|
166
167
|
packageLockPath: './package-lock.json',
|
|
167
168
|
packagePath: './package.json',
|
|
168
|
-
|
|
169
|
+
|
|
169
170
|
};
|
|
170
171
|
|
|
171
172
|
console.log('Welcome. The publishing operationg will begin.');
|
|
172
173
|
try {
|
|
173
|
-
settings["
|
|
174
|
+
settings["currentVersion"] = await getPackageJson(settings);
|
|
174
175
|
settings["newVersion"] = await getNewVersion();
|
|
175
176
|
|
|
176
|
-
|
|
177
|
-
|
|
177
|
+
await cleaningProject(settings);
|
|
178
|
+
await buildingBundle(settings);
|
|
178
179
|
await startPublishingVersion(settings);
|
|
179
180
|
await startGeneratingDocs(settings);
|
|
180
181
|
console.info('Finished Publishing');
|