pkgbld 1.25.0 → 1.27.0
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/README.md +20 -0
- package/dist/index.js +241 -43
- package/dist/src/eject.d.ts +2 -1
- package/dist/src/get-cli-options.d.ts +4 -1
- package/dist/src/helpers.d.ts +1 -1
- package/dist/src/load-plugins.d.ts +2 -1
- package/dist/src/prune.d.ts +4 -2
- package/dist/src/types.d.ts +1 -8
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -178,6 +178,14 @@ pkgbld --format-package-json
|
|
|
178
178
|
|
|
179
179
|
Formats package.json file.
|
|
180
180
|
|
|
181
|
+
### no-pack
|
|
182
|
+
|
|
183
|
+
Do not setup pack script in package.json
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
pkgbld --no-pack
|
|
187
|
+
```
|
|
188
|
+
|
|
181
189
|
### prune (command)
|
|
182
190
|
|
|
183
191
|
```
|
|
@@ -186,6 +194,18 @@ pkgbld prune
|
|
|
186
194
|
|
|
187
195
|
prune devDependencies and redundunt scripts from package.json
|
|
188
196
|
|
|
197
|
+
### flatten
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
pkgbld prune --flatten=<directory>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Flattens file structure by moving all files from `dist` or other directory to the root directory and updating package.json.
|
|
204
|
+
|
|
205
|
+
If the directory is not specified it is guessed from package.json.
|
|
206
|
+
|
|
207
|
+
If files cannot be copied because of name conflicts the command will fail.
|
|
208
|
+
|
|
189
209
|
## Plugin API
|
|
190
210
|
|
|
191
211
|
`pkgbld` reads all installed packages named `pkgbld-plugin-*` and assumes they are plugins
|
package/dist/index.js
CHANGED
|
@@ -141,6 +141,11 @@ const cliFlags = {
|
|
|
141
141
|
type: Boolean,
|
|
142
142
|
description: 'Format package.json',
|
|
143
143
|
default: cliFlagsDefaults.formatPackageJson
|
|
144
|
+
},
|
|
145
|
+
noPack: {
|
|
146
|
+
type: Boolean,
|
|
147
|
+
description: 'Do not pack',
|
|
148
|
+
default: false
|
|
144
149
|
}
|
|
145
150
|
};
|
|
146
151
|
const packageJsonFieldsOrder = new Set([
|
|
@@ -209,6 +214,15 @@ function toFormattedJson(json) {
|
|
|
209
214
|
return JSON.stringify(json, null, 2) + '\n';
|
|
210
215
|
}
|
|
211
216
|
|
|
217
|
+
function FlattenParam(value) {
|
|
218
|
+
if (typeof value === 'boolean') {
|
|
219
|
+
return value; // false
|
|
220
|
+
}
|
|
221
|
+
if (value === '') {
|
|
222
|
+
return true; // means auto
|
|
223
|
+
}
|
|
224
|
+
return value; // string
|
|
225
|
+
}
|
|
212
226
|
function getCliOptions(plugins, pkg) {
|
|
213
227
|
const cliOptions = cleye.cli({
|
|
214
228
|
name: 'pkgbld',
|
|
@@ -223,6 +237,11 @@ function getCliOptions(plugins, pkg) {
|
|
|
223
237
|
type: String,
|
|
224
238
|
description: 'profile to use',
|
|
225
239
|
default: 'library'
|
|
240
|
+
},
|
|
241
|
+
flatten: {
|
|
242
|
+
type: FlattenParam,
|
|
243
|
+
description: 'flatten package files',
|
|
244
|
+
default: false
|
|
226
245
|
}
|
|
227
246
|
}
|
|
228
247
|
})
|
|
@@ -231,7 +250,8 @@ function getCliOptions(plugins, pkg) {
|
|
|
231
250
|
if (cliOptions.command === 'prune') {
|
|
232
251
|
return {
|
|
233
252
|
kind: 'prune',
|
|
234
|
-
profile: cliOptions.flags.profile
|
|
253
|
+
profile: cliOptions.flags.profile,
|
|
254
|
+
flatten: cliOptions.flags.flatten
|
|
235
255
|
};
|
|
236
256
|
}
|
|
237
257
|
else {
|
|
@@ -254,7 +274,8 @@ function getCliOptions(plugins, pkg) {
|
|
|
254
274
|
commonjsPattern: flags.commonjsPattern,
|
|
255
275
|
esPattern: flags.esmPattern,
|
|
256
276
|
umdPattern: flags.umdPattern,
|
|
257
|
-
formatPackageJson: flags.formatPackageJson
|
|
277
|
+
formatPackageJson: flags.formatPackageJson,
|
|
278
|
+
noPack: flags.noPack
|
|
258
279
|
};
|
|
259
280
|
for (const plugin of plugins) {
|
|
260
281
|
plugin.options?.(flags, options);
|
|
@@ -658,7 +679,18 @@ async function getRollupConfigs([provider, plugins$1], inputs, config, helpers,
|
|
|
658
679
|
|
|
659
680
|
const mainLoggerText = (sourceDir, dir, configsCount, startingTime, finishedCount = 0) => (final = false) => `${sourceDir} → ${dir} ${final ? configsCount : finishedCount++} / ${configsCount}${final ? (' in ' + getTimeDiff(startingTime)) : ''}`;
|
|
660
681
|
|
|
682
|
+
const emptySet = new Set;
|
|
661
683
|
function processPackage(pkg, config, plugins) {
|
|
684
|
+
const exportsFields = new Set([
|
|
685
|
+
'types',
|
|
686
|
+
'import',
|
|
687
|
+
'require',
|
|
688
|
+
'svelte',
|
|
689
|
+
'default'
|
|
690
|
+
]);
|
|
691
|
+
const typingsFilePattern = '[name].d.ts';
|
|
692
|
+
const indexId = 'index';
|
|
693
|
+
const typesVersionsLastFields = new Set(['*']);
|
|
662
694
|
const inputs = [];
|
|
663
695
|
const logger$1 = logger.createLogger();
|
|
664
696
|
const allowEsm = (config.formatsOverridden && config.formats.includes('es') || !config.formatsOverridden);
|
|
@@ -684,7 +716,7 @@ function processPackage(pkg, config, plugins) {
|
|
|
684
716
|
if (typeof pkg.scripts !== 'object' && pkg.scripts !== null) {
|
|
685
717
|
pkg.scripts = {};
|
|
686
718
|
}
|
|
687
|
-
if (!('prepack' in pkg.scripts)) {
|
|
719
|
+
if (!config.noPack && !('prepack' in pkg.scripts)) {
|
|
688
720
|
const binary = typeof pkg.scripts.build === 'string' && pkg.scripts.build?.startsWith('pkgbld-internal') ? 'pkgbld-internal' : 'pkgbld';
|
|
689
721
|
pkg.scripts.prepack = `${binary} prune`;
|
|
690
722
|
}
|
|
@@ -700,9 +732,9 @@ function processPackage(pkg, config, plugins) {
|
|
|
700
732
|
}
|
|
701
733
|
pkg.types = `./${config.dir}/index.d.ts`;
|
|
702
734
|
if (allowUmd && typeof pkg.umd === 'string') {
|
|
703
|
-
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern,
|
|
704
|
-
if (!config.umdInputs.includes(
|
|
705
|
-
config.umdInputs.push(
|
|
735
|
+
pkg.umd = `./${config.dir}/${patternToName(config.umdPattern, indexId)}`;
|
|
736
|
+
if (!config.umdInputs.includes(indexId)) {
|
|
737
|
+
config.umdInputs.push(indexId);
|
|
706
738
|
}
|
|
707
739
|
}
|
|
708
740
|
if (config.bin) {
|
|
@@ -726,45 +758,57 @@ function processPackage(pkg, config, plugins) {
|
|
|
726
758
|
delete pkg.bin;
|
|
727
759
|
}
|
|
728
760
|
if (allowCjs) {
|
|
729
|
-
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern,
|
|
761
|
+
pkg.main = `./${config.dir}/${patternToName(config.commonjsPattern, indexId)}`;
|
|
730
762
|
}
|
|
731
763
|
if (allowEsm && !allowCjs) {
|
|
732
|
-
pkg.main = `./${config.dir}/${patternToName(config.esPattern,
|
|
764
|
+
pkg.main = `./${config.dir}/${patternToName(config.esPattern, indexId)}`;
|
|
733
765
|
}
|
|
734
766
|
if (allowCjs && pkg.main !== pkg.exports['.'].require) {
|
|
735
767
|
pkg.exports['.'].require = pkg.main;
|
|
736
768
|
}
|
|
737
769
|
if (allowCjs && allowEsm && typeof pkg.module !== 'string') {
|
|
738
|
-
pkg.module = `./${config.dir}/${patternToName(config.esPattern,
|
|
770
|
+
pkg.module = `./${config.dir}/${patternToName(config.esPattern, indexId)}`;
|
|
739
771
|
}
|
|
740
772
|
if (pkg.module !== pkg.exports['.']?.default) {
|
|
741
773
|
pkg.exports['.'].default = pkg.module;
|
|
742
774
|
}
|
|
743
|
-
if (allowUmd && config.umdInputs.includes(
|
|
744
|
-
pkg.unpkg = `./${config.dir}/${patternToName(config.umdPattern,
|
|
775
|
+
if (allowUmd && config.umdInputs.includes(indexId)) {
|
|
776
|
+
pkg.unpkg = `./${config.dir}/${patternToName(config.umdPattern, indexId)}`;
|
|
777
|
+
}
|
|
778
|
+
if (typeof pkg.typesVersions !== 'object' && pkg.typesVersions !== null) {
|
|
779
|
+
pkg.typesVersions = {};
|
|
780
|
+
}
|
|
781
|
+
if (typeof pkg.typesVersions['*'] !== 'object' && pkg.typesVersions['*'] !== null) {
|
|
782
|
+
pkg.typesVersions['*'] = {};
|
|
745
783
|
}
|
|
746
784
|
for (const id in pkg.exports) {
|
|
747
785
|
if (id === './package.json')
|
|
748
786
|
continue;
|
|
749
|
-
const basename = id == '.' ?
|
|
787
|
+
const basename = id == '.' ? indexId : path.basename(id);
|
|
750
788
|
if (typeof pkg.exports[id] !== 'object') {
|
|
751
789
|
pkg.exports[id] = {};
|
|
752
790
|
}
|
|
753
|
-
pkg.
|
|
791
|
+
pkg.typesVersions['*'][id] = [`${config.dir}/${patternToName(typingsFilePattern, basename)}`];
|
|
792
|
+
pkg.exports[id].types = `./${config.dir}/${patternToName(typingsFilePattern, basename)}`;
|
|
754
793
|
if (allowEsm) {
|
|
755
794
|
pkg.exports[id].import = `./${config.dir}/${patternToName(config.esPattern, basename)}`;
|
|
756
795
|
}
|
|
757
796
|
if (allowCjs) {
|
|
758
797
|
pkg.exports[id].require = `./${config.dir}/${patternToName(config.commonjsPattern, basename)}`;
|
|
759
798
|
}
|
|
760
|
-
pkg.exports[id] = orderFields(pkg.exports[id]);
|
|
761
|
-
if (basename !==
|
|
799
|
+
pkg.exports[id] = orderFields(exportsFields, pkg.exports[id]);
|
|
800
|
+
if (basename !== indexId) {
|
|
762
801
|
if (!pkg.files.includes(basename)) {
|
|
763
802
|
pkg.files.push(basename);
|
|
764
803
|
}
|
|
765
804
|
}
|
|
766
805
|
inputs.push(`./${config.sourceDir}/${basename}.ts`);
|
|
767
806
|
}
|
|
807
|
+
pkg.typesVersions['*']['*'] = [
|
|
808
|
+
`${config.dir}/${patternToName(typingsFilePattern, indexId)}`,
|
|
809
|
+
`${config.dir}/*`
|
|
810
|
+
];
|
|
811
|
+
pkg.typesVersions['*'] = orderFields(emptySet, pkg.typesVersions['*'], typesVersionsLastFields);
|
|
768
812
|
if (allowUmd && config.umdInputs.length > 0 && !config.formats.includes('umd')) {
|
|
769
813
|
config.formats.push('umd');
|
|
770
814
|
}
|
|
@@ -776,22 +820,20 @@ function processPackage(pkg, config, plugins) {
|
|
|
776
820
|
function patternToName(pattern, input) {
|
|
777
821
|
return pattern.replace('[name]', input);
|
|
778
822
|
}
|
|
779
|
-
|
|
780
|
-
'types',
|
|
781
|
-
'import',
|
|
782
|
-
'require',
|
|
783
|
-
'svelte',
|
|
784
|
-
'default'
|
|
785
|
-
]);
|
|
786
|
-
function orderFields(exports) {
|
|
823
|
+
function orderFields(firstFields, exports, lastFields = emptySet) {
|
|
787
824
|
const ordered = {};
|
|
788
|
-
for (const key of
|
|
825
|
+
for (const key of firstFields) {
|
|
789
826
|
if (key in exports) {
|
|
790
827
|
ordered[key] = exports[key];
|
|
791
828
|
}
|
|
792
829
|
}
|
|
793
830
|
for (const key in exports) {
|
|
794
|
-
if (!
|
|
831
|
+
if (!firstFields.has(key) && !lastFields.has(key)) {
|
|
832
|
+
ordered[key] = exports[key];
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
for (const key of lastFields) {
|
|
836
|
+
if (key in exports) {
|
|
795
837
|
ordered[key] = exports[key];
|
|
796
838
|
}
|
|
797
839
|
}
|
|
@@ -802,7 +844,7 @@ async function writeJson(path, json) {
|
|
|
802
844
|
await fs.writeFile(path, toFormattedJson(json));
|
|
803
845
|
}
|
|
804
846
|
|
|
805
|
-
var version = "1.
|
|
847
|
+
var version = "1.27.0";
|
|
806
848
|
var name = "pkgbld";
|
|
807
849
|
var license = "MIT";
|
|
808
850
|
var author = "Konstantin Shutkin";
|
|
@@ -841,10 +883,10 @@ var dependencies = {
|
|
|
841
883
|
rollup: "^4.0.0",
|
|
842
884
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
843
885
|
"rollup-plugin-preprocess": "^0.0.4",
|
|
844
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
886
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
845
887
|
"@rollup/plugin-terser": "^0.4.4",
|
|
846
888
|
"@rollup/plugin-json": "^6.0.1",
|
|
847
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
889
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
848
890
|
"@rollup-extras/plugin-clean": "^1.3.8",
|
|
849
891
|
"@rollup-extras/plugin-binify": "^1.1.9",
|
|
850
892
|
"@rollup-extras/plugin-externals": "^1.2.0",
|
|
@@ -853,7 +895,8 @@ var dependencies = {
|
|
|
853
895
|
"is-builtin-module": "^3.2.1",
|
|
854
896
|
terser: "^5.21.0",
|
|
855
897
|
kleur: "^4.1.5",
|
|
856
|
-
cleye: "^1.3.2"
|
|
898
|
+
cleye: "^1.3.2",
|
|
899
|
+
jsonata: "^2.0.3"
|
|
857
900
|
};
|
|
858
901
|
var devDependencies = {
|
|
859
902
|
"@types/lodash": "^4.14.199",
|
|
@@ -1028,31 +1071,186 @@ function loadPlugins(pkg) {
|
|
|
1028
1071
|
.map(packageName => import(packageName)));
|
|
1029
1072
|
}
|
|
1030
1073
|
|
|
1031
|
-
|
|
1032
|
-
'preinstall',
|
|
1033
|
-
'install',
|
|
1034
|
-
'postinstall',
|
|
1035
|
-
'prepublish',
|
|
1036
|
-
'preprepare',
|
|
1037
|
-
'prepare',
|
|
1038
|
-
'postprepare'
|
|
1039
|
-
]);
|
|
1040
|
-
function prunePkg(pkg, options) {
|
|
1074
|
+
async function prunePkg(pkg, options, logger) {
|
|
1041
1075
|
if (options.kind !== 'prune') {
|
|
1042
1076
|
throw new Error('prunePkg should only be called in prune mode');
|
|
1043
1077
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1078
|
+
const scriptsToKeep = getScriptsData();
|
|
1079
|
+
const keys = scriptsToKeep[options.profile];
|
|
1080
|
+
if (!keys) {
|
|
1081
|
+
throw new Error(`unknown profile ${options.profile}`);
|
|
1046
1082
|
}
|
|
1047
1083
|
delete pkg.devDependencies;
|
|
1048
1084
|
for (const key of Object.keys(pkg.scripts)) {
|
|
1049
|
-
if (!
|
|
1085
|
+
if (!keys.has(key)) {
|
|
1050
1086
|
delete pkg.scripts[key];
|
|
1051
1087
|
}
|
|
1052
1088
|
}
|
|
1053
1089
|
if (Object.keys(pkg.scripts).length === 0) {
|
|
1054
1090
|
delete pkg.scripts;
|
|
1055
1091
|
}
|
|
1092
|
+
if (options.flatten) {
|
|
1093
|
+
await flatten(pkg, options.flatten, logger);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
async function flatten(pkg, flatten, logger) {
|
|
1097
|
+
const { default: jsonata } = await import('jsonata');
|
|
1098
|
+
// find out where is the dist folder
|
|
1099
|
+
const expression = jsonata('[bin, main, module, unpkg, umd, types, typings, exports[].*.*, typesVersions.*.*]');
|
|
1100
|
+
const allReferences = (await expression.evaluate(pkg));
|
|
1101
|
+
let distDir;
|
|
1102
|
+
if (flatten === true) {
|
|
1103
|
+
let commonSegments;
|
|
1104
|
+
for (const entry of allReferences) {
|
|
1105
|
+
if (typeof entry !== 'string') {
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1108
|
+
const dirname = path.dirname(entry);
|
|
1109
|
+
const cleanedSegments = dirname.split('/').filter(path => path && path !== '.');
|
|
1110
|
+
if (!commonSegments) {
|
|
1111
|
+
commonSegments = cleanedSegments;
|
|
1112
|
+
}
|
|
1113
|
+
else {
|
|
1114
|
+
for (let i = 0; i < commonSegments.length; ++i) {
|
|
1115
|
+
if (commonSegments[i] !== cleanedSegments[i]) {
|
|
1116
|
+
commonSegments.length = i;
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
distDir = commonSegments?.join('/');
|
|
1123
|
+
}
|
|
1124
|
+
else {
|
|
1125
|
+
distDir = flatten;
|
|
1126
|
+
}
|
|
1127
|
+
if (!distDir) {
|
|
1128
|
+
throw new Error('could not find dist folder');
|
|
1129
|
+
}
|
|
1130
|
+
logger.update(`flattening ${distDir}...`);
|
|
1131
|
+
// check if dist can be flattened
|
|
1132
|
+
const relativeDistDir = './' + distDir;
|
|
1133
|
+
const existsPromises = [];
|
|
1134
|
+
const filesInDist = await walkDir(relativeDistDir);
|
|
1135
|
+
for (const file of filesInDist) {
|
|
1136
|
+
// check file is not in root dir
|
|
1137
|
+
const relativePath = path.relative(relativeDistDir, file);
|
|
1138
|
+
existsPromises.push(isExists(relativePath));
|
|
1139
|
+
}
|
|
1140
|
+
const exists = await Promise.all(existsPromises);
|
|
1141
|
+
const filesAlreadyExist = exists.filter(Boolean);
|
|
1142
|
+
if (filesAlreadyExist.length) {
|
|
1143
|
+
throw new Error(`dist folder cannot be flattened because files already exist: ${filesAlreadyExist.join(', ')}`);
|
|
1144
|
+
}
|
|
1145
|
+
// move files to root dir (rename)
|
|
1146
|
+
const renamePromises = [];
|
|
1147
|
+
const newFiles = [];
|
|
1148
|
+
for (const file of filesInDist) {
|
|
1149
|
+
// check file is not in root dir
|
|
1150
|
+
const relativePath = path.relative(relativeDistDir, file);
|
|
1151
|
+
newFiles.push(relativePath);
|
|
1152
|
+
renamePromises.push(fs.rename(file, relativePath));
|
|
1153
|
+
}
|
|
1154
|
+
await Promise.all(renamePromises);
|
|
1155
|
+
// remove dist folder
|
|
1156
|
+
try {
|
|
1157
|
+
await fs.rm(relativeDistDir, { recursive: true, force: true });
|
|
1158
|
+
}
|
|
1159
|
+
catch (e) {
|
|
1160
|
+
// ignore
|
|
1161
|
+
}
|
|
1162
|
+
const allReferencesSet = new Set(allReferences);
|
|
1163
|
+
// update package.json
|
|
1164
|
+
const stringToReplace = distDir + '/';
|
|
1165
|
+
const pkgClone = cloneAndUpdate(pkg, value => allReferencesSet.has(value) ? value.replace(stringToReplace, '') : value);
|
|
1166
|
+
Object.assign(pkg, pkgClone);
|
|
1167
|
+
// update files
|
|
1168
|
+
let files = pkg.files ?? [];
|
|
1169
|
+
files = files.filter(file => {
|
|
1170
|
+
let fileNormilized = path.normalize(file);
|
|
1171
|
+
if (fileNormilized.endsWith('/')) {
|
|
1172
|
+
// remove trailing slash
|
|
1173
|
+
fileNormilized = fileNormilized.slice(0, -1);
|
|
1174
|
+
}
|
|
1175
|
+
return fileNormilized !== distDir;
|
|
1176
|
+
});
|
|
1177
|
+
files.push(...newFiles);
|
|
1178
|
+
pkg.files = [...files];
|
|
1179
|
+
}
|
|
1180
|
+
function cloneAndUpdate(pkg, updater) {
|
|
1181
|
+
if (typeof pkg === 'string') {
|
|
1182
|
+
return updater(pkg);
|
|
1183
|
+
}
|
|
1184
|
+
if (Array.isArray(pkg)) {
|
|
1185
|
+
return pkg.map(value => cloneAndUpdate(value, updater));
|
|
1186
|
+
}
|
|
1187
|
+
if (typeof pkg === 'object' && pkg !== null) {
|
|
1188
|
+
const clone = {};
|
|
1189
|
+
for (const key of Object.keys(pkg)) {
|
|
1190
|
+
clone[key] = cloneAndUpdate(pkg[key], updater);
|
|
1191
|
+
}
|
|
1192
|
+
return clone;
|
|
1193
|
+
}
|
|
1194
|
+
return pkg;
|
|
1195
|
+
}
|
|
1196
|
+
async function isExists(file) {
|
|
1197
|
+
try {
|
|
1198
|
+
await fs.access(file);
|
|
1199
|
+
}
|
|
1200
|
+
catch (e) {
|
|
1201
|
+
if (typeof e === 'object' && e != null && 'code' in e && e.code === 'ENOENT') {
|
|
1202
|
+
return false;
|
|
1203
|
+
}
|
|
1204
|
+
throw e;
|
|
1205
|
+
}
|
|
1206
|
+
return file;
|
|
1207
|
+
}
|
|
1208
|
+
async function walkDir(dir) {
|
|
1209
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
1210
|
+
const files = [];
|
|
1211
|
+
await Promise.all(entries.map(entry => {
|
|
1212
|
+
const childPath = path.join(dir, entry.name);
|
|
1213
|
+
if (entry.isDirectory()) {
|
|
1214
|
+
return walkDir(childPath)
|
|
1215
|
+
.then(childFiles => {
|
|
1216
|
+
files.push(...childFiles);
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
else {
|
|
1220
|
+
files.push(childPath);
|
|
1221
|
+
}
|
|
1222
|
+
}).filter(Boolean));
|
|
1223
|
+
return files;
|
|
1224
|
+
}
|
|
1225
|
+
function getScriptsData() {
|
|
1226
|
+
const libraryScripts = new Set([
|
|
1227
|
+
'preinstall',
|
|
1228
|
+
'install',
|
|
1229
|
+
'postinstall',
|
|
1230
|
+
'prepublish',
|
|
1231
|
+
'preprepare',
|
|
1232
|
+
'prepare',
|
|
1233
|
+
'postprepare'
|
|
1234
|
+
]);
|
|
1235
|
+
const appScripts = new Set([
|
|
1236
|
+
...libraryScripts,
|
|
1237
|
+
'prestart',
|
|
1238
|
+
'start',
|
|
1239
|
+
'poststart',
|
|
1240
|
+
'prerestart',
|
|
1241
|
+
'restart',
|
|
1242
|
+
'postrestart',
|
|
1243
|
+
'prestop',
|
|
1244
|
+
'stop',
|
|
1245
|
+
'poststop',
|
|
1246
|
+
'pretest',
|
|
1247
|
+
'test',
|
|
1248
|
+
'posttest'
|
|
1249
|
+
]);
|
|
1250
|
+
return {
|
|
1251
|
+
library: libraryScripts,
|
|
1252
|
+
app: appScripts
|
|
1253
|
+
};
|
|
1056
1254
|
}
|
|
1057
1255
|
|
|
1058
1256
|
execute();
|
|
@@ -1070,7 +1268,7 @@ async function execute() {
|
|
|
1070
1268
|
process.stdout.moveCursor?.(0, -1);
|
|
1071
1269
|
const options = getCliOptions(plugins, pkg);
|
|
1072
1270
|
if (options.kind === 'prune') {
|
|
1073
|
-
prunePkg(pkg, options);
|
|
1271
|
+
await prunePkg(pkg, options, mainLogger);
|
|
1074
1272
|
await writeJson(pkgPath, pkg);
|
|
1075
1273
|
process.exit(0);
|
|
1076
1274
|
}
|
package/dist/src/eject.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { CliOptions,
|
|
1
|
+
import type { CliOptions, PkgbldRollupPlugin, Provider } from './types';
|
|
2
|
+
import type { PackageJson } from 'options';
|
|
2
3
|
import type { RollupOptions } from 'rollup';
|
|
3
4
|
import { getHelpers } from './helpers';
|
|
4
5
|
export declare function createEjectProvider(preimportMap: Map<string, Promise<never>>): Promise<[Provider, PkgbldRollupPlugin[]]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PkgbldPlugin } from './types';
|
|
2
|
+
import { PackageJson } from 'options';
|
|
2
3
|
export declare function getCliOptions(plugins: Partial<PkgbldPlugin>[], pkg: PackageJson): {
|
|
3
4
|
kind: 'build';
|
|
4
5
|
umdInputs: string[];
|
|
@@ -18,7 +19,9 @@ export declare function getCliOptions(plugins: Partial<PkgbldPlugin>[], pkg: Pac
|
|
|
18
19
|
esPattern: string;
|
|
19
20
|
umdPattern: string;
|
|
20
21
|
formatPackageJson: boolean;
|
|
22
|
+
noPack: boolean;
|
|
21
23
|
} | {
|
|
22
24
|
readonly kind: "prune";
|
|
23
25
|
readonly profile: string;
|
|
26
|
+
readonly flatten: string | boolean;
|
|
24
27
|
};
|
package/dist/src/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OutputOptions } from 'rollup';
|
|
2
|
-
import { PackageJson } from '
|
|
2
|
+
import { PackageJson } from 'options';
|
|
3
3
|
export declare function getHelpers(pkgName: string): {
|
|
4
4
|
getGlobalName: (anInput: string) => string;
|
|
5
5
|
getExternalGlobalName: (id: string) => string;
|
package/dist/src/prune.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Logger } from '@niceties/logger';
|
|
2
|
+
import { PackageJson } from 'options';
|
|
2
3
|
export declare function prunePkg(pkg: PackageJson, options: {
|
|
3
4
|
kind: 'prune';
|
|
4
5
|
profile: string;
|
|
5
|
-
|
|
6
|
+
flatten: string | boolean;
|
|
7
|
+
}, logger: Logger): Promise<void>;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { Plugin, InternalModuleFormat, OutputOptions } from 'rollup';
|
|
2
2
|
import type { getCliOptions } from './get-cli-options';
|
|
3
3
|
import { Logger } from '@niceties/logger';
|
|
4
|
+
import { PackageJson } from 'options';
|
|
4
5
|
export type Json = null | string | number | boolean | Json[] | {
|
|
5
6
|
[name: string]: Json;
|
|
6
7
|
};
|
|
7
|
-
export type PackageJson = {
|
|
8
|
-
name: string;
|
|
9
|
-
version: string;
|
|
10
|
-
dependencies?: Record<string, string>;
|
|
11
|
-
devDependencies?: Record<string, string>;
|
|
12
|
-
peerDependencies: Record<string, string>;
|
|
13
|
-
scripts?: Record<string, string>;
|
|
14
|
-
};
|
|
15
8
|
export declare const enum Priority {
|
|
16
9
|
preprocess = 1000,
|
|
17
10
|
cleanup = 1000,
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.27.0",
|
|
3
3
|
"name": "pkgbld",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Konstantin Shutkin",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"rollup": "^4.0.0",
|
|
34
34
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
35
35
|
"rollup-plugin-preprocess": "^0.0.4",
|
|
36
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
36
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
37
37
|
"@rollup/plugin-terser": "^0.4.4",
|
|
38
38
|
"@rollup/plugin-json": "^6.0.1",
|
|
39
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
39
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
40
40
|
"@rollup-extras/plugin-clean": "^1.3.8",
|
|
41
41
|
"@rollup-extras/plugin-binify": "^1.1.9",
|
|
42
42
|
"@rollup-extras/plugin-externals": "^1.2.0",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"is-builtin-module": "^3.2.1",
|
|
46
46
|
"terser": "^5.21.0",
|
|
47
47
|
"kleur": "^4.1.5",
|
|
48
|
-
"cleye": "^1.3.2"
|
|
48
|
+
"cleye": "^1.3.2",
|
|
49
|
+
"jsonata": "^2.0.3"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"typescript": "^5.2.2"
|