Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/lint-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint Release

on:
pull_request:
paths:
- '.github/workflows/lint-release.yml'
- 'packages/react-native-legal/**/package.json'
- 'packages/licenses-api/**/package.json'
- 'packages/license-kit/**/package.json'
- 'examples/**/package.json'
- 'examples/**/package.json'

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read

jobs:
lint-release:
name: Lint Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0

- name: Setup
uses: ./.github/actions/setup
with:
enable-cache: true

- name: Run linter
run: yarn lint:release
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
30 changes: 30 additions & 0 deletions examples/node-example/__utils__/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import child_process from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { stripVTControlCharacters } from 'node:util';

/**
Expand Down Expand Up @@ -61,3 +63,31 @@ export function runLicenseKit(args: string[] = []) {
);
});
}

/**
* All workspace packages that are not meant to be published to NPM need to be private
*
* The problem is that we would like to use some fixture packages for tests and for that we actually need
* to have them non-private :C
*
* The solution is to make them non-private only in test environment - jest exposes `globalSetup` and `globalTeardown`
* that we can use to monkey patch the packages before and after all test suite run (not ideal, but works)
*/
export function patchFixturesPackages(fixturesDir: string, isPrivate: boolean) {
for (const packageName of fs.readdirSync(fixturesDir)) {
if (packageName === 'example-private-package') {
continue;
}

const packagePath = path.join(fixturesDir, packageName, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packagePath, { encoding: 'utf8' }));

if (isPrivate) {
packageJson.private = true;
} else {
delete packageJson.private;
}

fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + '\n', { encoding: 'utf8' });
}
}
13 changes: 13 additions & 0 deletions examples/node-example/jest-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require('path');

const { patchFixturesPackages } = require('./__utils__/utils');

/**
* @param {import('@jest/types').Config.GlobalConfig} globalConfig
* @param {import('@jest/types').Config.ProjectConfig} projectConfig
*/
function setup(_globalConfig, _projectConfig) {
patchFixturesPackages(path.resolve(__dirname, '..', 'packages'), false);
}

module.exports = setup;
13 changes: 13 additions & 0 deletions examples/node-example/jest-teardown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require('path');

const { patchFixturesPackages } = require('./__utils__/utils');

/**
* @param {import('@jest/types').Config.GlobalConfig} globalConfig
* @param {import('@jest/types').Config.ProjectConfig} projectConfig
*/
function teardown(_globalConfig, _projectConfig) {
patchFixturesPackages(path.resolve(__dirname, '..', 'packages'), true);
}

module.exports = teardown;
2 changes: 2 additions & 0 deletions examples/node-example/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const config = {
testEnvironment: 'node',
setupFilesAfterEnv: ['jest-extended/all'],
testPathIgnorePatterns: ['__utils__'],
globalSetup: './jest-setup.js',
globalTeardown: './jest-teardown.js',
};

module.exports = config;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@callstack/example-additional-project-root-2",
"private": true,
"dependencies": {
"clsx": "2.1.1"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@callstack/example-additional-project-root",
"private": true,
"dependencies": {
"is-even": "1.0.0"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@callstack/example-copyleft-root-copyleft-avoidable-by-or-policy",
"private": true,
"description": "Test project for the license-kit copyleft exit code integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-apache-2.0-or-lgpl-3.0-and-mit-or-gpl-2.0": "workspace:*",
"@callstack/example-license-mit-or-gpl-3.0": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@callstack/example-copyleft-root-copyleft-unavoidable",
"private": true,
"description": "Test project for the license-kit copyleft exit code integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-gpl-3.0-and-mit-or-apache-2.0": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@callstack/example-copyleft-root-legacy-licenses-array",
"private": true,
"description": "Test project for the license-kit integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-legacy-licenses-array": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@callstack/example-copyleft-root-license-ref",
"private": true,
"description": "Test project for the license-kit integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-gpl-3.0-and-license-ref": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@callstack/example-copyleft-root-no-copyleft",
"private": true,
"description": "Test project for the license-kit copyleft exit code integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-mit-or-apache-2.0": "workspace:*",
"@callstack/example-license-mit-or-apache-2.0-and-isc": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@callstack/example-copyleft-root-unknown-licenses",
"private": true,
"description": "Test project for the license-kit integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-see-license-in": "workspace:*",
"@callstack/example-license-unlicensed": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@callstack/example-copyleft-root-weak-and-unidentified",
"private": true,
"description": "Test project for the license-kit integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-lgpl-2.1-and-license-ref": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@callstack/example-copyleft-root-weak-copyleft-only",
"private": true,
"description": "Test project for the license-kit copyleft exit code integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-mit-and-lgpl-2.1": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@callstack/example-copyleft-root-with-exception",
"private": true,
"description": "Test project for the license-kit integration tests",
"packageManager": "yarn@3.6.1",
"dependencies": {
"@callstack/example-license-gpl-2.0-with-classpath-exception": "workspace:*"
}
},
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with two Dual Licenses combined with AND, for the license-kit integration tests",
"license": "(Apache-2.0 OR LGPL-3.0-only) AND (MIT OR GPL-2.0-only)",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a License Exception and a COPYING file, for the example apps",
"license": "GPL-2.0-only WITH Classpath-exception-2.0",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a strong copyleft license and a License Exception, for the license-kit integration tests",
"license": "GPL-2.0-only WITH Classpath-exception-2.0",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with strong copyleft next to a custom license, for the license-kit integration tests",
"license": "GPL-3.0-only AND LicenseRef-Custom",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a strong copyleft license combined with AND with a Dual License, for the license-kit integration tests",
"license": "GPL-3.0-only AND (MIT OR Apache-2.0)",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"type": "Apache-2.0"
}
],
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with weak copyleft next to a custom license, for the license-kit integration tests",
"license": "LGPL-2.1-only AND LicenseRef-Custom",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a Dual License of a weak and a strong copyleft license, for the license-kit integration tests",
"license": "LGPL-2.1-only OR GPL-3.0-only",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
3 changes: 2 additions & 1 deletion examples/packages/example-license-lgpl-3.0-plus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with an LGPL-3.0+ license and a LICENSE.txt file, for the example apps",
"license": "LGPL-3.0+",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a permissive and a weak copyleft license combined with AND, for the license-kit integration tests",
"license": "MIT AND LGPL-2.1-only",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with an expression relying on AND binding tighter than OR, for the license-kit integration tests",
"license": "MIT OR Apache-2.0 AND ISC",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a Dual License and a single unlinked license file, for the example apps",
"license": "MIT OR Apache-2.0",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a Dual License of two permissive licenses, for the license-kit integration tests",
"license": "MIT OR Apache-2.0",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a Dual License nested inside AND, for the license-kit integration tests",
"license": "(MIT OR GPL-3.0-only) AND LGPL-2.1-only",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with a Dual License of a permissive and a strong copyleft license, for the license-kit integration tests",
"license": "MIT OR GPL-3.0-only",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package whose license points to a file, for the license-kit integration tests",
"license": "SEE LICENSE IN LICENSE.md",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
3 changes: 2 additions & 1 deletion examples/packages/example-license-unlicensed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"version": "1.0.0",
"description": "Test package with no license grant, for the license-kit integration tests",
"license": "UNLICENSED",
"packageManager": "yarn@3.6.1"
"packageManager": "yarn@3.6.1",
"private": true
}
4 changes: 4 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
pre-push:
piped: true
commands:
lint-release:
files: git diff --name-only --cached origin/main
glob: '*/package.json'
run: yarn lint:release
lint-js:
# Run ESLint for root ESLint config JS/TS files if any of them are staged
files: git diff --name-only --cached origin/main
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"build:library": "yarn workspace @callstack/licenses build && yarn workspace react-native-legal build-plugins && yarn workspace license-kit build-library && yarn workspace react-native-legal build-library",
"build:visualizer": "yarn workspace @callstack/license-kit-visualizer build",
"lint:release": "./scripts/lint-public-workspace-packages.js -p 'react-native-legal' -p 'license-kit' -p '@callstack/licenses' -i '**/node_modules/**' -i '**/dist/**' -i '**/lib/**' -i '**/visualizer-build/**'",
"lint:js": "eslint \"**/*.{js,ts,tsx}\"",
"lint:docs": "yarn workspace docs check",
"typescript": "yarn build:library && tsc --noEmit -p examples/bare-example/tsconfig.json && tsc --noEmit -p examples/bare-metro-graph-example/tsconfig.json && tsc --noEmit -p examples/expo-example/tsconfig.json && tsc --noEmit -p examples/expo-metro-graph-example/tsconfig.json",
Expand Down
Loading
Loading