Skip to content

Commit

Permalink
first commit 🛠
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Apr 12, 2024
0 parents commit 83f3d73
Show file tree
Hide file tree
Showing 18 changed files with 631 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
main/
module/
coverage/
71 changes: 71 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
module.exports = {
plugins: ['prettier'],
extends: ['eslint:recommended', 'prettier'],
parser: 'esprima',
parserOptions: {
ecmaVersion: 11,
requireConfigFile: false,
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
env: {
es6: true,
browser: true,
node: true,
jest: true
},
rules: {
'no-debugger': 2,
'no-alert': 2,
'no-await-in-loop': 0,
'no-prototype-builtins': 0,
'no-return-assign': ['error', 'except-parens'],
'no-restricted-syntax': [
2,
'ForInStatement',
'LabeledStatement',
'WithStatement'
],
'no-unused-vars': [
0,
{
ignoreSiblings: true,
argsIgnorePattern: 'React|res|next|^_'
}
],
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-unused-expressions': [
2,
{
allowTaggedTemplates: true
}
],
'no-console': 1,
'comma-dangle': 2,
'jsx-quotes': [2, 'prefer-double'],
'linebreak-style': ['error', 'unix'],
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
'prettier/prettier': [
'error',
{
trailingComma: 'none',
singleQuote: true,
printWidth: 80
}
]
}
};
30 changes: 30 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Tests

on:
push:

pull_request:
types: [opened, reopened]

workflow_dispatch:

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- name: checkout 🛎️
uses: actions/checkout@v4

- name: node
uses: actions/setup-node@v4
with:
node-version: 20.9.0

- name: Deps
run: |
yarn
yarn build
- name: Test
run: |
yarn test
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# dist
main
module

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Editors
.idea

# Lib
lib

# npm package lock
package-lock.json
yarn.lock

# others
.DS_Store
32 changes: 32 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
*.log
npm-debug.log*

protobuf
out
*.proto

# snapshots
*.snap

# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Dependency directories
node_modules

# npm package lock
package-lock.json
yarn.lock

# project files
__snapshots__
__fixtures__
__tests__
.editorconfig
.eslintignore
.eslintrc.js
.gitignore
.travis.yml
.vscode
CHANGELOG.md
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts-prepend-node-path=true
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"editor.formatOnSave": true,
"[javascriptreact]": {
"editor.formatOnSave": false
},
"[javascript]": {
"editor.formatOnSave": false
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
"javascriptreact"
],
"editor.insertSpaces": true,
"editor.tabSize": 2
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022 Dan Lynch <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# symlink-workspace

A utility tool for managing symlinks in a Lerna project with Yarn workspaces, designed to streamline local development by ensuring packages are properly linked. Specifically, links to the `dist/` folder so you can use `publishConfig.directory` set to `dist/` for advanced cjs/esm publishing, enabling tree-shaking ;)

## Table of Contents

- [Installation](#installation)
- [Features](#features)
- [Configuration](#configuration)
- [License](#license)

## Installation

```bash
yarn add --dev symlink-workspace
```

Will automatically read your Lerna configuration, identify package dependencies, and create symlinks from each package's `dist` directory to the corresponding `node_modules` directory.

## Features

- **Automated Symlink Creation:** Automatically creates symlinks for local dependencies in both individual packages and the root `node_modules` directory.
- **Support for Multiple Workspaces:** Seamlessly handles projects with multiple workspaces as defined in `lerna.json`.
- **Custom Configuration:** Allows customization of symlink paths based on specific project needs.


## License

Distributed under the MIT License. See `LICENSE` for more information.
75 changes: 75 additions & 0 deletions __tests__/options.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import objectPath from '../src';

describe('Object Path Operations', () => {
let obj;

beforeEach(() => {
obj = {
user: {
name: 'John Doe',
address: {
street: '123 Main St',
city: 'Anytown'
},
hobbies: ['reading', 'gaming', 'hiking']
}
};
});

describe('get', () => {
it('should retrieve a value at a given path', () => {
expect(objectPath.get(obj, 'user.name')).toBe('John Doe');
expect(objectPath.get(obj, 'user.address.city')).toBe('Anytown');
expect(objectPath.get(obj, 'user.hobbies[1]')).toBe('gaming');
expect(obj).toMatchSnapshot();
});

it('should return undefined for non-existent paths', () => {
expect(objectPath.get(obj, 'user.age')).toBeUndefined();
expect(objectPath.get(obj, 'user.address.zip')).toBeUndefined();
expect(objectPath.get(obj, 'user.hobbies[5]')).toBeUndefined();
expect(obj).toMatchSnapshot();
});
});

describe('set', () => {
it('should set a value at a given path', () => {
objectPath.set(obj, 'user.age', 30);
expect(obj.user.age).toBe(30);

objectPath.set(obj, 'user.address.zip', '12345');
expect(obj.user.address.zip).toBe('12345');

objectPath.set(obj, 'user.hobbies[2]', 'skiing');
expect(obj.user.hobbies[2]).toBe('skiing');

expect(obj).toMatchSnapshot();
});

it('should create nested structures if they do not exist', () => {
objectPath.set(obj, 'user.contact.phone', '123-456-7890');
expect(obj.user.contact.phone).toBe('123-456-7890');

objectPath.set(obj, 'user.hobbies[3]', 'swimming');
expect(obj.user.hobbies[3]).toBe('swimming');

expect(obj).toMatchSnapshot();
});
});

describe('has', () => {
it('should return true if a path exists', () => {
expect(objectPath.has(obj, 'user.name')).toBe(true);
expect(objectPath.has(obj, 'user.address.city')).toBe(true);
expect(objectPath.has(obj, 'user.hobbies[0]')).toBe(true);
expect(obj).toMatchSnapshot();
});

it('should return false if a path does not exist', () => {
expect(objectPath.has(obj, 'user.age')).toBe(false);
expect(objectPath.has(obj, 'user.address.zip')).toBe(false);
expect(objectPath.has(obj, 'user.hobbies[5]')).toBe(false);
expect(obj).toMatchSnapshot();
});
});
});
Loading

0 comments on commit 83f3d73

Please sign in to comment.