diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 344ccd5fe6..abd2800179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,10 +24,10 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16.x - cache: yarn key: node16 - name: Run ${{ matrix.command }} run: yarn && yarn build && yarn ${{ matrix.command }} env: CI: true + YARN_IGNORE_NODE: 1 diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml index 0fd62aa73e..5601e53526 100644 --- a/.github/workflows/comment.yml +++ b/.github/workflows/comment.yml @@ -45,10 +45,9 @@ jobs: - name: Setup node uses: actions/setup-node@v2 with: - node-version: 16.x - cache: yarn + node-version: 20.x registry-url: https://registry.npmjs.org - key: node16 + key: node20 - name: Install dependencies run: yarn diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae1d8e7629..ea8df0f7c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,15 +26,18 @@ jobs: uses: actions/setup-node@v2 with: node-version: 16.x - cache: yarn registry-url: https://registry.npmjs.org key: node16 - name: Install dependencies run: yarn + env: + YARN_IGNORE_NODE: 1 - name: Prepare release run: yarn prerelease + env: + YARN_IGNORE_NODE: 1 # https://github.com/changesets/action - name: Create release pull request or Publish to npm @@ -43,7 +46,7 @@ jobs: with: # defined in package.json#scripts version: yarn changesetversion - publish: yarn changeset publish + publish: node scripts/publish-fork.js env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.yarnrc.yml b/.yarnrc.yml index 5a46900a2d..53a05e5193 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,5 +1,7 @@ compressionLevel: mixed +nodeLinker: node-modules + enableGlobalCache: false packageExtensions: diff --git a/packages/slate-react/src/custom-types.ts b/packages/slate-react/src/custom-types.ts index 9c91b64c1d..c680c7498d 100644 --- a/packages/slate-react/src/custom-types.ts +++ b/packages/slate-react/src/custom-types.ts @@ -9,6 +9,7 @@ declare module 'slate' { } Range: BaseRange & { placeholder?: string + multiBlock?: boolean } } } diff --git a/scripts/publish-fork.js b/scripts/publish-fork.js new file mode 100644 index 0000000000..5ec6031b81 --- /dev/null +++ b/scripts/publish-fork.js @@ -0,0 +1,57 @@ +const fs = require('fs') +const path = require('path') +const { execSync } = require('child_process') + +const SLATE_PKG_PATH = path.resolve(__dirname, '../packages/slate/package.json') +const SLATE_REACT_PKG_PATH = path.resolve( + __dirname, + '../packages/slate-react/package.json' +) + +const originalSlatePkg = fs.readFileSync(SLATE_PKG_PATH, 'utf8') +const originalSlateReactPkg = fs.readFileSync(SLATE_REACT_PKG_PATH, 'utf8') + +try { + console.log('Mutating package.json files for @deepnote fork publication...') + + // 1. Mutate packages/slate/package.json + const slatePkg = JSON.parse(originalSlatePkg) + const slateVersion = slatePkg.version + slatePkg.name = '@deepnote/slate' + fs.writeFileSync(SLATE_PKG_PATH, JSON.stringify(slatePkg, null, 2) + '\n') + console.log(`Updated ${SLATE_PKG_PATH} name to @deepnote/slate`) + + // 2. Mutate packages/slate-react/package.json + const slateReactPkg = JSON.parse(originalSlateReactPkg) + slateReactPkg.name = '@deepnote/slate-react' + + const dependencyString = `npm:@deepnote/slate@${slateVersion}` + + if (slateReactPkg.dependencies && slateReactPkg.dependencies.slate) { + slateReactPkg.dependencies.slate = dependencyString + } + if (slateReactPkg.peerDependencies && slateReactPkg.peerDependencies.slate) { + slateReactPkg.peerDependencies.slate = dependencyString + } + + fs.writeFileSync( + SLATE_REACT_PKG_PATH, + JSON.stringify(slateReactPkg, null, 2) + '\n' + ) + console.log( + `Updated ${SLATE_REACT_PKG_PATH} name to @deepnote/slate-react and dependencies` + ) + + // 3. Run changeset publish + console.log('Running yarn changeset publish...') + execSync('yarn changeset publish', { stdio: 'inherit' }) +} catch (error) { + console.error('Error during publish-fork script:', error) + process.exit(1) +} finally { + // 4. Restore original package.json files + console.log('Restoring original package.json files...') + fs.writeFileSync(SLATE_PKG_PATH, originalSlatePkg) + fs.writeFileSync(SLATE_REACT_PKG_PATH, originalSlateReactPkg) + console.log('Restoration complete.') +}