Skip to content

Commit

Permalink
Initial randsamp release (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronccasanova committed Dec 17, 2022
1 parent 248d9b9 commit 49b1c6a
Show file tree
Hide file tree
Showing 12 changed files with 385 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-comics-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'randsamp': patch
---

Initial release
90 changes: 89 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version-packages": "changeset version",
"release": "turbo run build && changeset publish",
"tasks": "node scripts/tasks.mjs",
"generate": "plop"
"generate": "npm run build -- --filter=plop-dir && plop"
},
"devDependencies": {
"@aacc/eslint-config": "*",
Expand Down
10 changes: 10 additions & 0 deletions packages/randsamp/.babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@aacc/babel-preset",
{
"typescript": true
}
]
]
}
12 changes: 12 additions & 0 deletions packages/randsamp/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @type {import('eslint').Linter.Config}
*/
module.exports = {
root: true,
extends: ['@aacc/eslint-config/typescript'],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.eslint.json',
},
ignorePatterns: ['node_modules', 'dist', 'bin'],
}
20 changes: 20 additions & 0 deletions packages/randsamp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# randsamp

Randomizes samples from a target directory and hard links them to another

## Usage

```sh
npx randsamp \
--target ./path/to/target-directory \
--output ./path/to/output-directory
```

## Options

| Option | Description | Default |
| -------------- | ---------------------------------------------------------- | -------- |
| `-t, --target` | The target directory to collect and randomize samples | Required |
| `-o, --output` | The output directory to hard link the randomized samples | Required |
| `--ext` | Comma separated list of extension types to filter | `.wav` |
| `--count` | The number of samples to hard link in the output directory | `128` |
34 changes: 34 additions & 0 deletions packages/randsamp/bin/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

import * as util from 'node:util'

import { randsamp as _randsamp } from '../dist/esm/index.mjs'

const randsamp =
/** @type {typeof import('../dist/types/index.js').randsamp} */ (_randsamp)

const cli = util.parseArgs({
options: {
target: { type: 'string', short: 't' },
output: { type: 'string', short: 'o' },
ext: { type: 'string' },
count: { type: 'string' },
},
})

const { target: targetDir, output: outputDir, ext, count } = cli.values

if (!targetDir) {
throw new Error('targetDir is required')
}

if (!outputDir) {
throw new Error('outputDir is required')
}

await randsamp({
targetDir,
outputDir,
sampleExtensions: ext ? ext.split(',') : undefined,
sampleCount: count ? Number(count) : undefined,
})
67 changes: 67 additions & 0 deletions packages/randsamp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "randsamp",
"version": "0.0.0",
"description": "Randomizes samples from a target directory and hard links them to another",
"author": "Aaron Casanova <aaronccasanova@gmail.com>",
"license": "MIT",
"bin": "bin/index.mjs",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.mjs",
"types": "dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.js"
}
},
"engines": {
"node": ">=16.18.0"
},
"scripts": {
"start": "npm run build && node bin/index.mjs",
"dev": "npm-run-all --parallel 'build:* -- --watch'",
"build": "npm-run-all --parallel build:*",
"build:js": "rollup -c",
"build:types": "tsc --emitDeclarationOnly",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"lint": "TIMING=1 eslint . --ext .js,.ts --cache",
"prepublishOnly": "npm run build"
},
"files": [
"bin",
"dist"
],
"dependencies": {
"globby": "^11.1.0"
},
"devDependencies": {
"@aacc/babel-preset": "*",
"@aacc/browserslist-config": "*",
"@aacc/eslint-config": "*",
"@aacc/tsconfigs": "*",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-node-resolve": "^13.2.1",
"@types/node": "^18.11.16",
"rollup": "^2.70.2",
"typescript": "^4.7.3"
},
"browserslist": [
"extends @aacc/browserslist-config"
],
"publishConfig": {
"access": "public",
"@aacc:registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "git+https://github.com/aaronccasanova/aacc.git",
"directory": "packages/randsamp"
},
"bugs": {
"url": "https://github.com/aaronccasanova/aacc/issues"
},
"homepage": "https://github.com/aaronccasanova/aacc/blob/main/packages/randsamp/README.md"
}
49 changes: 49 additions & 0 deletions packages/randsamp/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import path from 'path'

import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from '@rollup/plugin-babel'

import pkg from './package.json'

const extensions = ['.js', '.jsx', '.ts', '.tsx']

/**
* @type {import('rollup').RollupOptions}
*/
export default {
input: 'src/index.ts',
output: [
{
format: /** @type {const} */ ('cjs'),
entryFileNames: '[name][assetExtname].js',
dir: path.dirname(pkg.main),
preserveModules: true,
},
{
format: /** @type {const} */ ('es'),
entryFileNames: '[name][assetExtname].mjs',
dir: path.dirname(pkg.module),
preserveModules: true,
},
],
plugins: [
// Allows node_modules resolution
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
nodeResolve({ extensions }),
// Allow bundling cjs modules. Rollup doesn't understand cjs
commonjs(),
// Compile TypeScript/JavaScript files
babel({
extensions,
babelHelpers: 'bundled',
include: ['src/**/*'],
}),
],
external: [
...Object.keys(pkg.dependencies ?? {}),
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
...Object.keys(pkg.peerDependencies ?? {}),
],
}

3 comments on commit 49b1c6a

@vercel
Copy link

@vercel vercel bot commented on 49b1c6a Dec 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

aacc-next-ts – ./recipes/next-ts

aacc-next-ts-aaronccasanova-gmailcom.vercel.app
aacc-next-ts.vercel.app
aacc-next-ts-git-main-aaronccasanova-gmailcom.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 49b1c6a Dec 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

aacc-next-ts-styled-comps – ./recipes/next-ts-styled-comps

aacc-next-ts-styled-comps-git-main-aaronccasanova-gmailcom.vercel.app
aacc-next-ts-styled-comps.vercel.app
aacc-next-ts-styled-comps-aaronccasanova-gmailcom.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 49b1c6a Dec 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.