pkgbld 1.8.0 → 1.9.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/dist/get-pkg.d.ts +2 -1
- package/dist/helpers.d.ts +8 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -22
- package/dist/process-pkg.d.ts +2 -1
- package/dist/types.d.ts +7 -0
- package/dist/write-pkg.d.ts +2 -1
- package/package.json +18 -17
package/dist/get-pkg.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Json } from './types';
|
|
2
|
+
export declare function getPackage(): Promise<[string, Json]>;
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { getCliOptions } from './get-cli-options';
|
|
2
|
-
|
|
2
|
+
import { OutputOptions } from 'rollup';
|
|
3
|
+
export declare function getHelpers(name: string): {
|
|
3
4
|
getGlobalName: (anInput: string) => string;
|
|
4
5
|
getExternalGlobalName: (id: string) => string;
|
|
5
6
|
umdFilter: typeof umdFilter;
|
|
6
7
|
};
|
|
7
8
|
export declare function umdFilter(config: ReturnType<typeof getCliOptions>, filename: string): boolean;
|
|
8
|
-
export declare function toArray<T>(object: T
|
|
9
|
+
export declare function toArray<T>(object: T | T[] | undefined): T[];
|
|
9
10
|
export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string, config: ReturnType<typeof getCliOptions>): boolean;
|
|
10
|
-
export declare function formatInput(input: string[] | string | undefined): string
|
|
11
|
-
export declare function formatOutput(output:
|
|
11
|
+
export declare function formatInput(input: string[] | string | undefined): string;
|
|
12
|
+
export declare function formatOutput(output: OutputOptions | OutputOptions[] | undefined, field: 'dir' | 'format'): string;
|
|
12
13
|
export declare function getTimeDiff(starting: number): string;
|
|
14
|
+
export declare function getDefaultExport<T extends {
|
|
15
|
+
default?: unknown;
|
|
16
|
+
}>(importedModule: T): {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import '@niceties/draftlog-appender';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
require('@niceties/draftlog-appender');
|
|
4
5
|
var logger = require('@niceties/logger');
|
|
5
6
|
var rollup = require('rollup');
|
|
6
7
|
var fs = require('fs/promises');
|
|
@@ -66,10 +67,9 @@ async function getPackage() {
|
|
|
66
67
|
return [pkgPath, JSON.parse(buffer.toString())];
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
function getHelpers(pkg) {
|
|
70
|
+
function getHelpers(name) {
|
|
71
71
|
function getGlobalName(anInput) {
|
|
72
|
-
return camelCase(path.join(
|
|
72
|
+
return camelCase(path.join(name, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
|
|
73
73
|
}
|
|
74
74
|
function getExternalGlobalName(id) {
|
|
75
75
|
if (path.isAbsolute(id)) {
|
|
@@ -91,6 +91,9 @@ function toArray(object) {
|
|
|
91
91
|
if (Array.isArray(object)) {
|
|
92
92
|
return object;
|
|
93
93
|
}
|
|
94
|
+
if (object == null) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
94
97
|
return [object];
|
|
95
98
|
}
|
|
96
99
|
function isExternalInput(id, inputs, currentInput, config) {
|
|
@@ -104,11 +107,15 @@ function isExternalInput(id, inputs, currentInput, config) {
|
|
|
104
107
|
return normalizedPath !== currentInput && inputs.includes(normalizedPath);
|
|
105
108
|
}
|
|
106
109
|
function formatInput(input) {
|
|
107
|
-
return Array.isArray(input) ? input.join(', ') : input;
|
|
110
|
+
return Array.isArray(input) ? input.join(', ') : (input !== null && input !== void 0 ? input : ''); // not sure if ?? '' needed
|
|
108
111
|
}
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
112
|
function formatOutput(output, field) {
|
|
111
|
-
|
|
113
|
+
var _a;
|
|
114
|
+
// can we avoid it?
|
|
115
|
+
if (output == null) {
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
return Array.isArray(output) ? output.map(item => item[field]).join(', ') : ((_a = output[field]) !== null && _a !== void 0 ? _a : '');
|
|
112
119
|
}
|
|
113
120
|
function getTimeDiff(starting) {
|
|
114
121
|
const now = Date.now();
|
|
@@ -131,18 +138,11 @@ function getBuildPlugins(format, config, inputs, currentInput) {
|
|
|
131
138
|
typescript()
|
|
132
139
|
];
|
|
133
140
|
if (config.preprocess.length) {
|
|
134
|
-
|
|
141
|
+
const context = { [format == 'es' ? 'esm' : 'cjs']: true };
|
|
142
|
+
result.unshift(preprocess({ include: config.preprocess.map(name => `${config.sourceDir}/${name}.ts`), context }));
|
|
135
143
|
}
|
|
136
144
|
return result;
|
|
137
145
|
}
|
|
138
|
-
function getPreprocessContext(format) {
|
|
139
|
-
if (format == 'es') {
|
|
140
|
-
return { esm: true };
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
return { cjs: true };
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
146
|
function getOutputPlugins(format, config) {
|
|
147
147
|
return config.compressTargets.includes(format) ? [rollupPluginTerser.terser({
|
|
148
148
|
mangle: {
|
|
@@ -197,28 +197,31 @@ function getRollupConfigs(inputs, config, helpers) {
|
|
|
197
197
|
},
|
|
198
198
|
plugins: getBuildPlugins('umd', config, inputs, currentInput)
|
|
199
199
|
}));
|
|
200
|
-
if (umdConfigs
|
|
200
|
+
if (umdConfigs.length) {
|
|
201
201
|
configs.push(...umdConfigs);
|
|
202
202
|
}
|
|
203
203
|
return configs;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
206
|
function processPackage(pkg, config) {
|
|
208
207
|
var _a;
|
|
209
208
|
const input = [];
|
|
210
209
|
const logger$1 = logger.createLogger();
|
|
211
|
-
if (typeof pkg
|
|
210
|
+
if (typeof pkg !== 'object' || Array.isArray(pkg)) {
|
|
211
|
+
logger$1.finish('expecting object on top level of package.json', 3 /* LogLevel.error */);
|
|
212
|
+
process.exit(-1);
|
|
213
|
+
}
|
|
214
|
+
if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) !== 'string') {
|
|
212
215
|
logger$1.finish('expecting name to be a string in package.json', 3 /* LogLevel.error */);
|
|
213
216
|
process.exit(-1);
|
|
214
217
|
}
|
|
215
|
-
if (!Array.isArray(pkg.files)) {
|
|
218
|
+
if (!Array.isArray(pkg === null || pkg === void 0 ? void 0 : pkg.files)) {
|
|
216
219
|
pkg.files = [];
|
|
217
220
|
}
|
|
218
221
|
if (!pkg.files.includes(config.dir)) {
|
|
219
222
|
pkg.files.push(config.dir);
|
|
220
223
|
}
|
|
221
|
-
if (typeof pkg.exports !== 'object') {
|
|
224
|
+
if (typeof pkg.exports !== 'object' && pkg.exports !== null) {
|
|
222
225
|
pkg.exports = {};
|
|
223
226
|
}
|
|
224
227
|
if (pkg.exports['.'] == null) {
|
|
@@ -265,7 +268,6 @@ function processPackage(pkg, config) {
|
|
|
265
268
|
return input;
|
|
266
269
|
}
|
|
267
270
|
|
|
268
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
269
271
|
async function writePackage(pkgPath, pkg) {
|
|
270
272
|
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
271
273
|
}
|
|
@@ -275,7 +277,7 @@ async function execute() {
|
|
|
275
277
|
const [pkgPath, pkg] = await getPackage();
|
|
276
278
|
const config = getCliOptions();
|
|
277
279
|
const inputs = processPackage(pkg, config);
|
|
278
|
-
const helpers = getHelpers(pkg);
|
|
280
|
+
const helpers = getHelpers(pkg.name);
|
|
279
281
|
const rollupConfigs = getRollupConfigs(inputs, config, helpers);
|
|
280
282
|
for (const config of rollupConfigs) {
|
|
281
283
|
const logger$1 = logger.createLogger();
|
package/dist/process-pkg.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { getCliOptions } from './get-cli-options';
|
|
2
|
-
|
|
2
|
+
import { Json } from './types';
|
|
3
|
+
export declare function processPackage(pkg: Json, config: ReturnType<typeof getCliOptions>): string[];
|
package/dist/types.d.ts
ADDED
package/dist/write-pkg.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Json } from './types';
|
|
2
|
+
export declare function writePackage(pkgPath: string, pkg: Json): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.9.1",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "pkgbld",
|
|
5
5
|
"author": {
|
|
@@ -35,35 +35,36 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@semantic-release/changelog": "6.0.1",
|
|
38
|
-
"@semantic-release/commit-analyzer": "9.0.
|
|
38
|
+
"@semantic-release/commit-analyzer": "9.0.2",
|
|
39
39
|
"@semantic-release/git": "10.0.1",
|
|
40
|
-
"@semantic-release/npm": "
|
|
41
|
-
"@semantic-release/release-notes-generator": "10.0.
|
|
42
|
-
"@types/lodash": "4.14.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
44
|
-
"@typescript-eslint/parser": "5.
|
|
40
|
+
"@semantic-release/npm": "9.0.1",
|
|
41
|
+
"@semantic-release/release-notes-generator": "10.0.3",
|
|
42
|
+
"@types/lodash": "4.14.186",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "5.41.0",
|
|
44
|
+
"@typescript-eslint/parser": "5.41.0",
|
|
45
45
|
"conventional-changelog-angular": "5.0.13",
|
|
46
|
-
"eslint": "8.
|
|
47
|
-
"semantic-release": "19.0.
|
|
48
|
-
"@rollup-extras/plugin-binify": "1.1.
|
|
46
|
+
"eslint": "8.26.0",
|
|
47
|
+
"semantic-release": "19.0.5",
|
|
48
|
+
"@rollup-extras/plugin-binify": "1.1.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@niceties/logger": "1.1.
|
|
51
|
+
"@niceties/logger": "1.1.9",
|
|
52
|
+
"@niceties/draftlog-appender": "1.2.6",
|
|
52
53
|
"lodash": "4.17.21",
|
|
53
|
-
"rollup": "3.
|
|
54
|
+
"rollup": "3.2.5",
|
|
54
55
|
"rollup-plugin-terser": "7.0.2",
|
|
55
56
|
"rollup-plugin-typescript2": "0.34.1",
|
|
56
57
|
"rollup-plugin-preprocess": "0.0.4",
|
|
57
|
-
"@rollup/plugin-commonjs": "23.0.
|
|
58
|
-
"@rollup/plugin-node-resolve": "15.0.
|
|
59
|
-
"@rollup-extras/plugin-clean": "1.3.
|
|
60
|
-
"@rollup-extras/plugin-externals": "1.1.
|
|
58
|
+
"@rollup/plugin-commonjs": "23.0.2",
|
|
59
|
+
"@rollup/plugin-node-resolve": "15.0.1",
|
|
60
|
+
"@rollup-extras/plugin-clean": "1.3.2",
|
|
61
|
+
"@rollup-extras/plugin-externals": "1.1.3",
|
|
61
62
|
"typescript": "4.8.4",
|
|
62
63
|
"minimist": "1.2.7"
|
|
63
64
|
},
|
|
64
65
|
"overrides": {
|
|
65
66
|
"rollup-plugin-terser@7.0.2": {
|
|
66
|
-
"rollup": "3.
|
|
67
|
+
"rollup": "3.2.5"
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
}
|