|
| 1 | +// Copyright 2024 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +// Prepares lite (core) version of zx to publish |
| 16 | + |
| 17 | +import fs from 'node:fs' |
| 18 | +import path from 'node:path' |
| 19 | + |
| 20 | +const __dirname = path.dirname(new URL(import.meta.url).pathname) |
| 21 | +const root = path.resolve(__dirname, '..') |
| 22 | +const pkgJsonFile = path.join(root, 'package.json') |
| 23 | +const _pkgJson = JSON.parse(fs.readFileSync(pkgJsonFile, 'utf-8')) |
| 24 | + |
| 25 | +const pkgJson = { |
| 26 | + ..._pkgJson, |
| 27 | + version: _pkgJson.version + '-lite', |
| 28 | + exports: { |
| 29 | + '.': { |
| 30 | + types: './build/core.d.ts', |
| 31 | + import: './build/core.js', |
| 32 | + require: './build/core.cjs', |
| 33 | + default: './build/core.js', |
| 34 | + }, |
| 35 | + './package.json': './package.json', |
| 36 | + }, |
| 37 | + main: './build/core.cjs', |
| 38 | + types: './build/core.d.ts', |
| 39 | + typesVersions: { |
| 40 | + '*': { |
| 41 | + '.': ['./build/core.d.ts'], |
| 42 | + }, |
| 43 | + }, |
| 44 | + man: undefined, |
| 45 | + files: [ |
| 46 | + 'build/core.cjs', |
| 47 | + 'build/core.js', |
| 48 | + 'build/core.d.ts', |
| 49 | + 'build/deno.js', |
| 50 | + 'build/esblib.js', |
| 51 | + 'build/util.cjs', |
| 52 | + 'build/util.js', |
| 53 | + 'build/util.d.ts', |
| 54 | + 'build/vendor-core.cjs', |
| 55 | + 'build/vendor-core.js', |
| 56 | + 'build/vendor-core.d.ts', |
| 57 | + ], |
| 58 | +} |
| 59 | + |
| 60 | +fs.writeFileSync(pkgJsonFile, JSON.stringify(pkgJson, null, 2)) |
| 61 | + |
| 62 | +console.log('package.json prepared for zx-lite') |
0 commit comments