create-ncblock 0.0.3 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ncblock",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Create a Notion custom view block project.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,7 @@ import {
12
12
  } from "fs"
13
13
  import { tmpdir } from "os"
14
14
  import { resolve } from "path"
15
+ import { cleanDist, stagePublishDir } from "./compile-sdk"
15
16
 
16
17
  type StoredTemplateMetadata = {
17
18
  title?: string
@@ -145,15 +146,19 @@ function readSdkVersion(root: string): string {
145
146
 
146
147
  function packLocalSdk(root: string, dest: string): string {
147
148
  const sdkDir = resolve(root, "sdk")
148
- const tgzOutput = execSync("npm pack --pack-destination .", {
149
- cwd: sdkDir,
150
- encoding: "utf-8",
151
- }).trim()
152
- const tgz = tgzOutput.split(/\r?\n/).at(-1) ?? tgzOutput
153
- const tgzPath = resolve(sdkDir, tgz)
154
- copyFileSync(tgzPath, resolve(dest, tgz))
155
- rmSync(tgzPath, { force: true })
156
- return `file:./${tgz}`
149
+ const publishDir = stagePublishDir(sdkDir)
150
+ try {
151
+ const tgzOutput = execSync("npm pack --pack-destination .", {
152
+ cwd: publishDir,
153
+ encoding: "utf-8",
154
+ }).trim()
155
+ const tgz = tgzOutput.split(/\r?\n/).at(-1) ?? tgzOutput
156
+ copyFileSync(resolve(publishDir, tgz), resolve(dest, tgz))
157
+ return `file:./${tgz}`
158
+ } finally {
159
+ rmSync(publishDir, { recursive: true, force: true })
160
+ cleanDist(sdkDir)
161
+ }
157
162
  }
158
163
 
159
164
  function copyDirectoryContents(