Skip to content

Commit

Permalink
chore: setup monorepo (#1679)
Browse files Browse the repository at this point in the history
* chore: monorepo

* lerna initial

* chore: more reasonable package.json

* yarn.lock

* chore(rulesets): package.json + no deps on no longer existing files

* chore: cli version

* chore: ver 0.0.0

* chore: publish from-package

* chore: io package

* chore: use yarn workspaces

* chore: setup build & Jest

* chore: sort out dependencies

* chore: setup Karma

* revert: reduce diff

* chore: ts build

* chore: test-harness

* chore: use lerna bootstrap in CI

* chore: deps

* revert: \!

* build: lint docs

* chore: lint commit messages

* chore: downgrade Karma

* docs: cli flags

* chore: do not forget about npx

* chore: windoooows

* chore: --experimental-modules for Node 12.8 on Windows

* chore: redundant commit-msg hook

* chore: now?

Co-authored-by: Dom Kriskovic <[email protected]>
  • Loading branch information
P0lip and Dom Kriskovic authored Jun 22, 2021
1 parent e3a457a commit 43ed54c
Show file tree
Hide file tree
Showing 401 changed files with 5,305 additions and 2,374 deletions.
53 changes: 37 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ commands:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
command: |
npx lerna bootstrap
! git diff --name-only | grep yarn.lock
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
Expand All @@ -34,11 +36,30 @@ commands:
name: Build the code
command: yarn build

lint:
lint-code:
steps:
- run:
name: Lint code
command: yarn lint.eslint

lint-documentation:
steps:
- run:
name: Lint documentation
command: yarn lint.prettier

lint-changelog:
steps:
- run:
name: Lint the code
command: yarn lint
name: Lint changelog
command: yarn lint.changelog

lint-commit-message:
steps:
- run:
name: Lint commit messages
command: |
echo "$(git log -1 --pretty=format:"%s")" | npx commitlint
test-node:
steps:
Expand All @@ -50,10 +71,7 @@ commands:
steps:
- run:
name: Create the Spectral Binary
command: yarn build.binary
- run:
name: Create output directory
command: mkdir ./test-harness/tmp
command: npx lerna run build.binary --scope=@stoplight/spectral-cli
- run:
name: Run harness tests
command: yarn test.harness
Expand All @@ -64,7 +82,6 @@ commands:
- cached-dependencies
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm version from-git
- run: yarn inline-version
- run: yarn build

jobs:
Expand All @@ -74,7 +91,10 @@ jobs:
steps:
- checkout
- cached-dependencies
- lint
- lint-commit-message
- lint-changelog
- lint-code
- lint-documentation

test:
parameters:
Expand Down Expand Up @@ -111,17 +131,18 @@ jobs:
name: windows/default
steps:
- checkout
- install-and-build
- run: npx lerna bootstrap -- --ignore-engines
- run: yarn build
- test-node

build-windows-binary:
executor:
name: windows/default
steps:
- prepare-release
- run: npx pkg . --targets windows --out-path ./binaries
- run: yarn lerna exec "pkg . --targets windows --out-path ./binaries" --scope=@stoplight/spectral-cli
- persist_to_workspace:
root: ./
root: ./packages/cli/
paths:
- binaries

Expand Down Expand Up @@ -194,9 +215,9 @@ jobs:
else
npm publish
fi
- run: npx pkg . --targets linux,macos,alpine --out-path ./binaries
- run: lerna exec "pkg . --targets linux,macos,alpine --out-path ./binaries" --scope=@stoplight/spectral-cli
- persist_to_workspace:
root: ./
root: ./packages/cli/
paths:
- binaries

Expand All @@ -211,7 +232,7 @@ jobs:
command: go get github.com/tcnksm/ghr
- run:
name: "Publish Release artifacts on GitHub"
command: ghr -t ${GH_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} /tmp/binaries
command: ghr -t ${GH_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${CIRCLE_TAG} /tmp/packages/cli/binaries

workflows:
commit:
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/__fixtures__/**
/test-harness/**/*.yaml
/packages/*/dist
17 changes: 10 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,31 @@
"overrides": [
{
"files": [
"src/**/*.ts"
"packages/*/src/**/*.ts"
],
"parserOptions": {
"project": "./tsconfig.eslint.json"
},
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["import"],
"rules": {
"@typescript-eslint/prefer-regexp-exec": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-floating-promises": ["error", { "ignoreVoid": true }],
"@typescript-eslint/strict-boolean-expressions": "warn",
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/ban-types": "warn"
"@typescript-eslint/ban-types": "warn",

"import/no-extraneous-dependencies": ["error", { "devDependencies": ["**/*.{test,spec}.ts", "**/__helpers__/tester.ts"] }]
}
},

{
"files": [
"src/cli/**/*.ts"
"packages/cli/src/**/*.ts"
],
"rules": {
"no-console": "warn"
Expand All @@ -59,7 +62,7 @@

{
"files": [
"src/**/__tests__/*.ts",
"packages/*/src/**/__tests__/*.ts",
"test-harness/**/*.{ts,js}"
],
"rules": {
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

/binaries
/rulesets
/__karma__/__fixtures__/
packages/cli/binaries
/test-harness/tmp/
packages/*/dist

# testing
/coverage
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
npx --no-install commitlint --edit $1
25 changes: 13 additions & 12 deletions docs/guides/2-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ spectral lint ./reference/**/*.oas*.{json,yml,yaml}
Other options include:

```text
--version Show version number [boolean]
--help Show help [boolean]
--encoding, -e text encoding to use [string] [default: "utf8"]
--version Show version number [boolean]
--help Show help [boolean]
-e, --encoding text encoding to use
[string] [choices: "utf8", "ascii", "utf-8", "utf16le", "ucs2", "ucs-2", "base64", "latin1"] [default: "utf8"]
--format, -f formatter to use for outputting results
[string] [choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty"] [default: "stylish"]
--output, -o output to a file instead of stdout [string]
--resolver path to custom json-ref-resolver instance [string]
--ruleset, -r path/URL to a ruleset file [string]
[string] [choices: "json", "stylish", "junit", "html", "text", "teamcity", "pretty"] [default: "stylish"]
--output, -o output to a file instead of stdout [string]
--resolver path to custom json-ref-resolver instance [string]
--ruleset, -r path/URL to a ruleset file [string]
--fail-severity, -F results of this level or above will trigger a failure exit code
[string] [choices: "error", "warn", "info", "hint"] [default: "error"]
--display-only-failures, -D only output results equal to or greater than --fail-severity
[boolean] [default: false]
--ignore-unknown-format do not warn about unmatched formats [boolean] [default: false]
--fail-on-unmatched-globs fail on unmatched glob patterns [boolean] [default: false]
--verbose, -v increase verbosity [boolean]
--quiet, -q no logging - output only [boolean]
[boolean] [default: false]
--ignore-unknown-format do not warn about unmatched formats [boolean] [default: false]
--fail-on-unmatched-globs fail on unmatched glob patterns [boolean] [default: false]
--verbose, -v increase verbosity [boolean]
--quiet, -q no logging - output only [boolean]
```

The Spectral CLI supports loading documents as YAML or JSON, and validation of OpenAPI v2/v3 documents via our built-in ruleset.
Expand Down
44 changes: 43 additions & 1 deletion docs/migration-guides/6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,49 @@

## Core

### Functions
1. `run` does not accept `{ documentUri }`. Please use `Document` and specify the source of the document there.

Workaround:

```ts
import { Document, Spectral } from "@stoplight/spectral-core";
import { Json as JsonParser } from "@stoplight/spectral-parsers";
import * as path from "@stoplight/path";

const s = new Spectral();

const doc = new Document(
`{
"street": null
}`,
JsonParser,
path.join(__dirname, "street-doc.json"),
);

await spectral.run(doc);
```

2. Spectral constructor

```ts
import { Document, Spectral } from "@stoplight/spectral-core";
import { Json as JsonParser } from "@stoplight/spectral-parsers";
import * as path from "@stoplight/path";

const s = new Spectral();

const doc = new Document(
`{
"street": null
}`,
JsonParser,
path.join(__dirname, "street-doc.json"),
);

await spectral.run(doc);
```

## Functions

1. `schema` function uses Ajv v8 in favor of Ajv v6. It is preferred to provide JSON Schema Draft 7 schemas or newer, albeit older drafts are also supported via json-schema-migrate.
`oasVersion` is no longer supported. Use `oasSchema` function from the OAS ruleset if you want to supply OAS Schema Object.
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/asyncapi-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ info:
title: Descriptive API
description: >+
Some description about the general point of this API, and why it exists when another similar but different API also exists.
```

### asyncapi-info-license-url
Expand Down Expand Up @@ -314,7 +313,6 @@ tags:
- name: Invoice Items
description: |+
Giant long explanation about what this business concept is, because other people _might_ not have a clue!
```

**Recommended:** No
Expand Down
8 changes: 1 addition & 7 deletions docs/reference/openapi-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,7 @@ info:
version: "1.0.0"
title: Descriptive API
description: >+
Some description about the general point of this API, and why it exists when another similar but different API also exists.
## Authentication
This API uses OAuth2 and tokens can be requested from [Dev Portal: Tokens](https://example.org/developers/tokens).
Some description about the general point of this API, and why it exists when another similar but different API also exists.## AuthenticationThis API uses OAuth2 and tokens can be requested from [Dev Portal: Tokens](https://example.org/developers/tokens).
```

### info-license
Expand Down Expand Up @@ -354,7 +349,6 @@ tags:
- name: Invoice Items
description: |+
Giant long explanation about what this business concept is, because other people _might_ not have a clue!
```

**Recommended:** No
Expand Down
Loading

0 comments on commit 43ed54c

Please sign in to comment.