Skip to content

Commit

Permalink
new: Add @moonrepo/types package. (#292)
Browse files Browse the repository at this point in the history
* Add types package.

* Add project and tasks.

* Add types.

* Update runtime to use types.

* Update license.

* Update deps.

* Update readme.

* Update docusaurus.

* Update blog.

* Add astro commands.

* Add version patch.

* Sync project refs.

* Remove node 14.

* Add task deps.
  • Loading branch information
milesj committed Aug 31, 2022
1 parent 832ed37 commit eb6c879
Show file tree
Hide file tree
Showing 36 changed files with 1,433 additions and 1,289 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [14, 16, 18]
node-version: [16, 18]
steps:
- uses: actions/checkout@v3
with:
Expand Down
13 changes: 7 additions & 6 deletions .moon/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ fileGroups:

tasks:
build:
command: 'packemon'
args: 'build --addFiles --declaration'
command: 'packemon build --addFiles --addExports --declaration'
env:
NODE_ENV: 'production'
inputs:
Expand All @@ -22,6 +21,7 @@ tasks:
- '/tsconfig.options.json'
outputs:
- 'cjs'
- 'dts'

format:
command: 'prettier'
Expand Down Expand Up @@ -55,6 +55,8 @@ tasks:
- '--no-error-on-unmatched-pattern'
- '--report-unused-disable-directives'
- '.'
deps:
- '^:build'
inputs:
- '@globs(sources)'
- '@globs(tests)'
Expand All @@ -80,10 +82,9 @@ tasks:
- 'jest.config.js'

typecheck:
command: 'tsc'
args:
- '--build'
- '--verbose'
command: 'tsc --build --verbose'
deps:
- '^:build'
inputs:
- '@globs(sources)'
- '@globs(tests)'
Expand Down
13 changes: 8 additions & 5 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

$schema: '../schemas/workspace.json'

projects:
- 'packages/*'
- '!packages/cli'
- '!packages/core-*'
- 'website'

node:
version: '16.15.0'
packageManager: 'yarn'
Expand All @@ -10,11 +16,8 @@ node:
addEnginesConstraint: false
inferTasksFromScripts: false

projects:
- 'packages/*'
- '!packages/cli'
- '!packages/core-*'
- 'website'
typescript:
syncProjectReferences: true

runner:
logRunningCommand: true
Expand Down
18 changes: 10 additions & 8 deletions .yarn/versions/b3d934b9.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
releases:
"@moonrepo/cli": minor
"@moonrepo/core-linux-arm64-gnu": minor
"@moonrepo/core-linux-arm64-musl": minor
"@moonrepo/core-linux-x64-gnu": minor
"@moonrepo/core-linux-x64-musl": minor
"@moonrepo/core-macos-arm64": minor
"@moonrepo/core-macos-x64": minor
"@moonrepo/core-windows-x64-msvc": minor
'@moonrepo/cli': minor
'@moonrepo/core-linux-arm64-gnu': minor
'@moonrepo/core-linux-arm64-musl': minor
'@moonrepo/core-linux-x64-gnu': minor
'@moonrepo/core-linux-x64-musl': minor
'@moonrepo/core-macos-arm64': minor
'@moonrepo/core-macos-x64': minor
'@moonrepo/core-windows-x64-msvc': minor
'@moonrepo/runtime': patch
'@moonrepo/types': patch
2 changes: 2 additions & 0 deletions crates/action/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub enum ActionStatus {
}

#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Attempt {
pub duration: Option<Duration>,

Expand Down Expand Up @@ -54,6 +55,7 @@ impl Attempt {
}

#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Action {
pub attempts: Option<Vec<Attempt>>,

Expand Down
1 change: 1 addition & 0 deletions crates/action/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub enum ProfileType {
}

#[derive(Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ActionContext {
pub passthrough_args: Vec<String>,

Expand Down
2 changes: 1 addition & 1 deletion crates/platform-node/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ lazy_static! {

// This isn't exhaustive but captures very popular tools
pub static ref DEV_COMMAND: regex::Regex =
regex::create_regex(r#"(concurrently)|(gatsby (new|dev|develop|serve|repl))|(next (dev|start))|(packemon watch)|(parcel [^build])|(react-scripts start)|(snowpack dev)|(vite (dev|preview|serve))|(vue-cli-service serve)|(webpack (s|serve|server|w|watch|-))"#)
regex::create_regex(r#"(astro (dev|preview))|(concurrently)|(gatsby (new|dev|develop|serve|repl))|(next (dev|start))|(packemon watch)|(parcel [^build])|(react-scripts start)|(snowpack dev)|(vite (dev|preview|serve))|(vue-cli-service serve)|(webpack (s|serve|server|w|watch|-))"#)
.unwrap();

pub static ref DEV_COMMAND_SOLO: regex::Regex =
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"execa": "^6.1.0",
"jest": "^28.1.3",
"jest-preset-moon": "^1.0.0",
"packemon": "^2.3.3",
"packemon": "^2.4.0",
"prettier": "^2.7.1",
"prettier-config-moon": "^1.0.0",
"tsconfig-moon": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Updated hashing to utilize the resolved version from the lockfile when applicable.
- Updated the action runner to fail when an output is defined and the output does not exist after
being ran.
- Released a new `@moonrepo/types` npm package.

#### ⚙️ Internal

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 moon, Miles Johnson
Copyright (c) 2021 moonrepo LLC, Miles Johnson

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,
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Moon, Miles Johnson
Copyright (c) 2021 moonrepo LLC, Miles Johnson

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,
Expand Down
8 changes: 8 additions & 0 deletions packages/runtime/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# @moonrepo/runtime

> IN DEVELOPMENT!
![build status](https://img.shields.io/github/workflow/status/moonrepo/moon/Moon)
![npm version](https://img.shields.io/npm/v/@moonrepo/runtime)
![npm license](https://img.shields.io/npm/l/@moonrepo/runtime)

Utilities for creating custom task executors within moon's runtime.
2 changes: 2 additions & 0 deletions packages/runtime/moon.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
language: typescript
type: library

dependsOn: [types]
6 changes: 2 additions & 4 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
"bundle": true
},
"dependencies": {
"@boost/common": "^3.2.1"
"@boost/common": "^4.0.0",
"@moonrepo/types": "^0.0.0"
},
"engines": {
"node": ">=14.15.0",
"npm": ">=6.14.0"
},
"exports": {
"./package.json": "./package.json",
"./*": {
"types": "./dts/*.d.ts"
},
".": {
"types": "./dts/index.d.ts",
"node": {
Expand Down
17 changes: 6 additions & 11 deletions packages/runtime/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import fs from 'fs';
import { json, Path } from '@boost/common';
import { Project } from './types';
import { Project } from '@moonrepo/types';

export interface RuntimeContext {
project: Project;
projectRoot: Path;
target: string;
workspace: {
root: Path;
};
workspaceRoot: Path;
}

export async function getContext(): Promise<RuntimeContext> {
Expand All @@ -20,13 +19,9 @@ export async function getContext(): Promise<RuntimeContext> {
const project = json.parse<Project>(await fs.promises.readFile(env.MOON_PROJECT_RUNFILE, 'utf8'));

return {
project: {
...project,
root: Path.create(project.root),
},
project,
projectRoot: Path.create(project.root),
target: env.MOON_TARGET!,
workspace: {
root: Path.create(env.MOON_WORKSPACE_ROOT ?? process.cwd()),
},
workspaceRoot: Path.create(env.MOON_WORKSPACE_ROOT ?? process.cwd()),
};
}
1 change: 0 additions & 1 deletion packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './context';
export * from './types';
5 changes: 5 additions & 0 deletions packages/runtime/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
"src/**/*",
"tests/**/*",
"types/**/*"
],
"references": [
{
"path": "../types"
}
]
}
18 changes: 18 additions & 0 deletions packages/types/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT License

Copyright (c) 2021 moonrepo LLC, Miles Johnson

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.
7 changes: 7 additions & 0 deletions packages/types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @moonrepo/types

![build status](https://img.shields.io/github/workflow/status/moonrepo/moon/Moon)
![npm version](https://img.shields.io/npm/v/@moonrepo/types)
![npm license](https://img.shields.io/npm/l/@moonrepo/types)

Reusable TypeScript types for moon projects, tasks, and configurations.
2 changes: 2 additions & 0 deletions packages/types/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language: typescript
type: library
45 changes: 45 additions & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@moonrepo/types",
"version": "0.0.0",
"type": "commonjs",
"description": "TypeScript types for moon.",
"keywords": [
"moon",
"repo",
"typescript",
"types"
],
"author": "Miles Johnson",
"license": "MIT",
"main": "./cjs/index.cjs",
"types": "./dts/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/moonrepo/moon",
"directory": "packages/types"
},
"files": [
"cjs/**/*.{cjs,mjs,map}",
"dts/**/*.d.ts",
"src/**/*.{ts,tsx,json}"
],
"packemon": {
"format": "cjs",
"platform": "node",
"bundle": true
},
"engines": {
"node": ">=14.15.0",
"npm": ">=6.14.0"
},
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dts/index.d.ts",
"node": {
"import": "./cjs/index-wrapper.mjs",
"require": "./cjs/index.cjs"
}
}
}
}
1 change: 1 addition & 0 deletions packages/types/src/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Platform = 'node' | 'system' | 'unknown';
Loading

0 comments on commit eb6c879

Please sign in to comment.