1
+ import fs from 'fs' ;
1
2
import path from 'path' ;
2
3
3
4
import babel from '@rollup/plugin-babel' ;
@@ -9,16 +10,14 @@ import ts from 'rollup-plugin-typescript2';
9
10
10
11
import generatorConfig from '../../openapitools.json' ;
11
12
12
- import { version } from './version' ;
13
-
14
13
// Retrieve package to build
15
14
const client = process . env . CLIENT ?. replace (
16
15
'@experimental-api-clients-automation/' ,
17
16
''
18
17
) ;
19
18
const UTILS = [ 'client-common' , 'requester-browser-xhr' , 'requester-node-http' ] ;
20
19
21
- function createLicence ( name ) {
20
+ function createLicence ( name , version ) {
22
21
return `/*! ${ name } .umd.js | ${ version } | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */` ;
23
22
}
24
23
@@ -113,7 +112,7 @@ function initPackagesConfig() {
113
112
const availableClients = getAvailableClients ( ) ;
114
113
115
114
if ( availableClients . length === 0 ) {
116
- throw new Error ( `No clients matching ${ client } .` ) ;
115
+ throw new Error ( `No clients matches ' ${ client } ' .` ) ;
117
116
}
118
117
119
118
return availableClients . flatMap ( ( packageName ) => {
@@ -169,6 +168,14 @@ const rollupConfig = [];
169
168
170
169
packagesConfig . forEach ( ( packageConfig ) => {
171
170
const clientPath = path . resolve ( 'packages' , packageConfig . package ) ;
171
+ const clientPackage = JSON . parse (
172
+ fs . readFileSync ( path . resolve ( clientPath , 'package.json' ) )
173
+ ) ;
174
+
175
+ if ( ! clientPackage ) {
176
+ throw new Error ( `No package.json found for '${ packageConfig . name } '` ) ;
177
+ }
178
+
172
179
const bundlers = createBundlers ( {
173
180
output : packageConfig . output ,
174
181
clientPath,
@@ -183,7 +190,10 @@ packagesConfig.forEach((packageConfig) => {
183
190
184
191
if ( isUmdBuild ) {
185
192
output . name = packageConfig . name ;
186
- output . banner = createLicence ( packageConfig . package ) ;
193
+ output . banner = createLicence (
194
+ packageConfig . package ,
195
+ clientPackage . version
196
+ ) ;
187
197
}
188
198
189
199
const compressorPlugins = isUmdBuild ? [ terser ( ) ] : [ ] ;
0 commit comments