main
 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
15import { tempdir, $, path, fs } from '../../build/index.js'
16import { describe, before, after, it } from 'node:test'
17
18const __dirname = path.dirname(new URL(import.meta.url).pathname)
19const root = path.resolve(__dirname, '../../')
20
21describe('jsr artifact', () => {
22  let tmp
23  let t$
24
25  before(async () => {
26    tmp = tempdir()
27    t$ = $({ cwd: tmp, quiet: true })
28
29    // copy all for jsr publish
30    await Promise.all(
31      [
32        'src/',
33        'tsconfig.json',
34        'LICENSE',
35        'README.md',
36        'scripts/build-jsr.mjs',
37        'package.json',
38      ].map((filepath) =>
39        fs.copy(
40          path.resolve(path.join(root, filepath)),
41          path.resolve(path.join(tmp, filepath))
42        )
43      )
44    )
45    await t$`ln -s ${path.resolve(root, 'node_modules')} ${path.resolve(tmp, 'node_modules')}`
46  })
47  after(() => fs.remove(tmp))
48
49  it('publish --dry-run`', async () => {
50    await t$`node scripts/build-jsr.mjs`
51    await t$({ quiet: false })`jsr publish --dry-run`
52  })
53})