Home / File/ pack-packages.mjs — tailwindcss Source File

pack-packages.mjs — tailwindcss Source File

Architecture documentation for pack-packages.mjs, a javascript file in the tailwindcss codebase. 5 imports, 0 dependents.

File javascript OxideEngine PreProcessors 5 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  eb559df0_b69a_d2f1_b447_203907613ec8["pack-packages.mjs"]
  8d4c06fc_a152_c497_9c1b_b60c5c91b817["node:child_process"]
  eb559df0_b69a_d2f1_b447_203907613ec8 --> 8d4c06fc_a152_c497_9c1b_b60c5c91b817
  8118fcf2_a51d_d1a1_93d3_c71d3a646692["promises"]
  eb559df0_b69a_d2f1_b447_203907613ec8 --> 8118fcf2_a51d_d1a1_93d3_c71d3a646692
  6697e014_f05e_326e_fc13_a0cc17f46c5d["node:os"]
  eb559df0_b69a_d2f1_b447_203907613ec8 --> 6697e014_f05e_326e_fc13_a0cc17f46c5d
  2a7660a5_3e09_bd74_37f0_e4e54bc64ce5["node:path"]
  eb559df0_b69a_d2f1_b447_203907613ec8 --> 2a7660a5_3e09_bd74_37f0_e4e54bc64ce5
  83f4eb5c_a623_9c4e_b3f7_d95e77d40d82["node:url"]
  eb559df0_b69a_d2f1_b447_203907613ec8 --> 83f4eb5c_a623_9c4e_b3f7_d95e77d40d82
  style eb559df0_b69a_d2f1_b447_203907613ec8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { exec, execSync } from 'node:child_process'
import fs from 'node:fs/promises'
import { platform } from 'node:os'
import path, { dirname } from 'node:path'
import url from 'node:url'

const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
let root = path.resolve(__dirname, '..')

let command = platform() === 'win32' ? 'cd' : 'pwd'
let rawPaths = execSync(`pnpm --silent --filter=!./playgrounds/* -r exec ${command}`).toString()

let paths = rawPaths
  .trim()
  .split(/\r?\n/)
  .map((x) => path.join(x, 'package.json'))

let workspaces = new Map()

// Track all the workspaces
for (let path of paths) {
  let pkg = await fs.readFile(path, 'utf8').then(JSON.parse)
  if (pkg.private) continue
  workspaces.set(pkg.name, { version: pkg.version ?? '', dir: dirname(path) })
}

// Clean dist folder
await fs.rm(path.join(root, 'dist'), { recursive: true, force: true })

Promise.all(
  [...workspaces.entries()].map(async ([name, { dir }]) => {
    function pack() {
      return new Promise((resolve) => {
        exec(
          `pnpm pack --pack-gzip-level=0 --pack-destination="${path.join(root, 'dist').replace(/\\/g, '\\\\')}"`,
          { cwd: dir },
          (err, stdout, stderr) => {
            if (err) {
              console.error(err, stdout, stderr)
            }

            resolve(lastLine(stdout.trim()))
          },
        )
      })
    }

    let filename = await pack()
    // Remove version suffix
    await fs.rename(
      path.join(root, 'dist', path.basename(filename)),
      path.join(root, 'dist', pkgToFilename(name)),
    )
  }),
).then(() => {
  console.log('Done.')
})

function pkgToFilename(name) {
  return `${name.replace('@', '').replace('/', '-')}.tgz`
}

function lastLine(str) {
  let index = str.lastIndexOf('\n')
  if (index === -1) return str
  return str.slice(index + 1)
}

Domain

Subdomains

Dependencies

  • node:child_process
  • node:os
  • node:path
  • node:url
  • promises

Frequently Asked Questions

What does pack-packages.mjs do?
pack-packages.mjs is a source file in the tailwindcss codebase, written in javascript. It belongs to the OxideEngine domain, PreProcessors subdomain.
What functions are defined in pack-packages.mjs?
pack-packages.mjs defines 3 function(s): lastLine, paths, pkgToFilename.
What does pack-packages.mjs depend on?
pack-packages.mjs imports 5 module(s): node:child_process, node:os, node:path, node:url, promises.
Where is pack-packages.mjs in the architecture?
pack-packages.mjs is located at scripts/pack-packages.mjs (domain: OxideEngine, subdomain: PreProcessors, directory: scripts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free