Skip to content

Commit 547d9b4

Browse files
authored
Merge pull request #114 from aminya/monorepo [skip ci]
2 parents 2b1515a + 1df74e7 commit 547d9b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2096
-335
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ temp-*
1111
*.tsbuildinfo
1212

1313
# Build directories
14-
./dist/
15-
!./dist/setup_cpp.js
16-
!./dist/setup_cpp.js.map
14+
packages/*/dist/
1715
.parcel-cache
1816
exe/
1917
*.log
2018
*.exe
21-
.cache/
19+
.cache/

cspell.config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@ words:
1414
- applellvm
1515
- bazel
1616
- bazelisk
17-
- copr
18-
- vbatts
1917
- buildtools
2018
- caxa
2119
- ccache
2220
- choco
2321
- cmake
22+
- copr
2423
- CPATH
2524
- Cppcheck
2625
- CPPFLAGS
@@ -38,6 +37,7 @@ words:
3837
- ghes
3938
- Graphviz
4039
- isci
40+
- isroot
4141
- kcov
4242
- LDFLAGS
4343
- lefticus
@@ -68,6 +68,7 @@ words:
6868
- tsbuildinfo
6969
- ucrt
7070
- untildify
71+
- vbatts
7172
- vcpkg
7273
- vcvarsall
7374
- visualc

dev/readme/template.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<h1 align="center"><%= projectName %></h1>
2+
<p>
3+
<% if (isProjectOnNpm) { -%>
4+
<a href="https://www.npmjs.com/package/<%= projectName %>" target="_blank">
5+
<img alt="Version" src="https://img.shields.io/npm/v/<%= projectName %>.svg">
6+
</a>
7+
<% } -%>
8+
<% if (projectVersion && !isProjectOnNpm) { -%>
9+
<img alt="Version" src="https://img.shields.io/badge/version-<%= projectVersion %>-blue.svg?cacheSeconds=2592000" />
10+
<% } -%>
11+
<% if (projectPrerequisites) { -%>
12+
<% projectPrerequisites.map(({ name, value }) => { -%>
13+
<img src="https://img.shields.io/badge/<%= name %>-<%= encodeURIComponent(value) %>-blue.svg" />
14+
<% }) -%>
15+
<% } -%>
16+
<% if (projectDocumentationUrl) { -%>
17+
<a href="<%= projectDocumentationUrl %>" target="_blank">
18+
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-brightgreen.svg" />
19+
</a>
20+
<% } -%>
21+
<% if (isGithubRepos) { -%>
22+
<a href="<%= repositoryUrl %>/graphs/commit-activity" target="_blank">
23+
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" />
24+
</a>
25+
<% } -%>
26+
<% if (licenseName) { -%>
27+
<a href="<%= licenseUrl ? licenseUrl : '#' %>" target="_blank">
28+
<img alt="License: <%= licenseName %>" src="https://img.shields.io/<%= isGithubRepos ? `github/license/${authorGithubUsername}/${projectName}` : `badge/License-${licenseName}-yellow.svg` %>" />
29+
</a>
30+
<% } -%>
31+
<% if (authorTwitterUsername) { -%>
32+
<a href="https://twitter.com/<%= authorTwitterUsername %>" target="_blank">
33+
<img alt="Twitter: <%= authorTwitterUsername %>" src="https://img.shields.io/twitter/follow/<%= authorTwitterUsername %>.svg?style=social" />
34+
</a>
35+
<% } -%>
36+
</p>
37+
<% if (projectDescription) { -%>
38+
39+
> <%= projectDescription %>
40+
> <% } -%>
41+
42+
## Install
43+
44+
```sh
45+
npm install --save <%= projectName %>
46+
```
47+
48+
## Usage
49+
50+
<!-- INSERT GENERATED DOCS START -->
51+
52+
<!-- INSERT GENERATED DOCS END -->
53+
54+
## 🤝 Contributing
55+
56+
You can sponsor my work here:
57+
58+
https://github.com/sponsors/aminya
59+
60+
Pull requests, issues and feature requests are welcome.
61+
See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md).

dist/actions_python.073441c2.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/actions_python.073441c2.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/actions_python.4e47ab32.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

dist/actions_python.4e47ab32.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/actions_python.dfab21e0.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions_python.dfab21e0.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions_python.feac98a0.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions_python.feac98a0.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/setup_cpp.mjs.map

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

package.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
"clean": "shx rm -rf .parcel-cache dist exe",
2828
"copy.matchers": "shx cp ./src/gcc/gcc_matcher.json ./dist/ && shx cp ./src/msvc/msvc_matcher.json ./dist && shx cp ./src/python/python_matcher.json ./dist/ && shx cp ./src/llvm/llvm_matcher.json ./dist/ ",
2929
"dev": "cross-env NODE_ENV=development parcel watch",
30+
"docs": "shx rm -rf packages/*/README.md && pnpm -r exec readme --path ../../dev/readme/template.md -y && pnpm -r exec ts-readme",
3031
"format": "run-s lint.prettier",
3132
"lint": "run-p --aggregate-output --continue-on-error lint.cspell lint.eslint lint.prettier lint.tsc",
3233
"lint.cspell": "cspell lint --no-progress --show-suggestions",
3334
"lint.eslint": "eslint **/*.{ts,tsx,js,jsx,cjs,mjs,json,yaml} --no-error-on-unmatched-pattern --cache --cache-location ./.cache/eslint/ --fix",
3435
"lint.prettier": "prettier --write .",
3536
"lint.tsc": "tsc --noEmit | loose-ts-check",
3637
"pack.exe": "shx rm -rf ./dist/tsconfig.tsbuildinfo && node ./dev/scripts/pack-exe.js",
37-
"prepare": "npm run build",
38+
"prepare": "pnpm run -r build && pnpm run -w build",
3839
"start.docker": "docker run -t setup_cpp .",
3940
"start.docker.arch": "docker run -t setup_cpp:arch .",
4041
"start.docker.fedora": "docker run -t setup_cpp:fedora .",
@@ -54,16 +55,22 @@
5455
"@actions/exec": "^1.1.1",
5556
"@actions/io": "^1.1.2",
5657
"@actions/tool-cache": "^2.0.1",
57-
"escape-path-with-spaces": "^1.0.0",
58+
"@npmcli/ci-detect": "github:aminya/ci-detect#37fe40075bebec96794ba0a7c4a6d5c70cbea00d",
59+
"escape-path-with-spaces": "github:aminya/escape-path-with-spaces#d9f81ee649203ddc55783a2f96ada59df06118e3",
60+
"exec-powershell": "workspace:*",
5861
"execa": "^5.1.1",
62+
"extension-tools": "workspace:*",
63+
"get-works": "workspace:*",
5964
"mri": "^1.2.0",
6065
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#9f672c1",
6166
"numerous": "1.0.3",
67+
"root-tools": "workspace:*",
6268
"semver": "7.3.7",
6369
"setup-python": "github:actions/setup-python#c474c82340438924daab9282d07300bfe7e3692d",
6470
"time-delta": "github:aminya/time-delta#69d91a41cef28e569be9a2991129f5f7d1f0d00e",
6571
"ubuntu-version": "^2.0.0",
66-
"untildify": "^4.0.0",
72+
"untildify-user": "workspace:*",
73+
"user-access": "workspace:*",
6774
"which": "^2.0.2"
6875
},
6976
"devDependencies": {
@@ -79,16 +86,19 @@
7986
"cspell": "^6.5.0",
8087
"eslint": "^8.21.0",
8188
"eslint-config-atomic": "^1.18.1",
89+
"gen-readme": "^1.6.0",
8290
"jest": "^28.1.3",
8391
"loose-ts-check": "^1.2.0",
8492
"npm-check-updates": "^16.0.5",
8593
"npm-run-all2": "^6.0.1",
8694
"parcel": "2.6.2",
8795
"prettier": "2.7.1",
8896
"prettier-config-atomic": "^3.0.10",
97+
"readme-md-generator": "^1.0.0",
8998
"shx": "0.3.4",
9099
"terser-config-atomic": "^0.1.1",
91100
"ts-jest": "^28.0.7",
101+
"ts-readme": "^1.1.3",
92102
"typescript": "^4.7.4"
93103
},
94104
"engines": {
@@ -113,6 +123,9 @@
113123
"ninja",
114124
"meson"
115125
],
126+
"alias": {
127+
"electron": false
128+
},
116129
"pnpm": {
117130
"overrides": {
118131
"semver": "7.3.7",

packages/exec-powershell/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<h1 align="center">exec-powershell</h1>
2+
<p>
3+
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
4+
<a href="#" target="_blank">
5+
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
6+
</a>
7+
</p>
8+
9+
> Run a powershell command.
10+
11+
## Install
12+
13+
```sh
14+
npm install --save exec-powershell
15+
```
16+
17+
## Usage
18+
19+
<!-- INSERT GENERATED DOCS START -->
20+
21+
### `execPowershell` (function)
22+
23+
Asynchronously execute a powershell command.
24+
25+
**Parameters:**
26+
27+
- command (`string`) - The powershell command to execute
28+
- startupFlags (`string[]`) - The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
29+
- execOptions (`execa.Options`) - The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
30+
31+
**returns:** execa.ExecaChildProcess<string>
32+
33+
### `execPowershellSync` (function)
34+
35+
Execute a powershell command.
36+
37+
**Parameters:**
38+
39+
- command (`string`) - The powershell command to execute
40+
- startupFlags (`string[]`) - The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo", "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
41+
- execOptions (`execa.SyncOptions`) - The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
42+
43+
**returns:** execa.ExecaSyncReturnValue<string>
44+
45+
### `getPowerShell` (function)
46+
47+
Get the path to the powershell executable.
48+
49+
**returns:** string
50+
51+
<!-- INSERT GENERATED DOCS END -->
52+
53+
## 🤝 Contributing
54+
55+
You can sponsor my work here:
56+
57+
https://github.com/sponsors/aminya
58+
59+
Pull requests, issues and feature requests are welcome.
60+
See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md).

packages/exec-powershell/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "exec-powershell",
3+
"version": "1.0.0",
4+
"description": "Run a powershell command.",
5+
"homepage": "https://github.com/aminya/setup-cpp",
6+
"license": "Apache-2.0",
7+
"author": "Amin Yahyaabadi",
8+
"main": "./dist/index.js",
9+
"source": "./src/index.ts",
10+
"scripts": {
11+
"build": "tsc"
12+
},
13+
"dependencies": {
14+
"execa": "^5.1.1",
15+
"which": "^2.0.2"
16+
},
17+
"devDependencies": {
18+
"@types/which": "^2.0.1"
19+
},
20+
"keywords": [
21+
"powershell",
22+
"pwsh",
23+
"exec",
24+
"execa",
25+
"spawn",
26+
"system",
27+
"github-actions",
28+
"github",
29+
"actions",
30+
"gitlab",
31+
"ci"
32+
]
33+
}

packages/exec-powershell/src/index.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import execa from "execa"
2+
import which from "which"
3+
4+
/** The cached powershell path */
5+
let powershell: string | undefined
6+
7+
/**
8+
* Asynchronously execute a powershell command.
9+
*
10+
* @param command The powershell command to execute
11+
* @param startupFlags The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo",
12+
* "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
13+
* @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
14+
* @returns A promise to the execution result
15+
* @note It prefers `pwsh` over `powershell`
16+
*/
17+
export function execPowershell(
18+
command: string,
19+
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
20+
execOptions: execa.Options = { stdio: "inherit" }
21+
): execa.ExecaChildProcess<string> {
22+
return execa(getPowerShell(), [...startupFlags, "-c", command], execOptions)
23+
}
24+
25+
/**
26+
* Execute a powershell command.
27+
*
28+
* @param command The powershell command to execute
29+
* @param startupFlags The optional startup flags to be passed to powershell. Defaults to `["-NoProfile", "-NoLogo",
30+
* "-NonInteractive"]`. This means that the Powershell profile is not sourced first.
31+
* @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit" }`
32+
* @returns The execution result
33+
* @note It prefers `pwsh` over `powershell`
34+
*/
35+
export function execPowershellSync(
36+
command: string,
37+
startupFlags: string[] = ["-NoProfile", "-NoLogo", "-NonInteractive"],
38+
execOptions: execa.SyncOptions = { stdio: "inherit" }
39+
): execa.ExecaSyncReturnValue<string> {
40+
return execa.sync(getPowerShell(), [...startupFlags, "-c", command], execOptions)
41+
}
42+
43+
/**
44+
* Get the path to the powershell executable.
45+
*
46+
* @note It prefers `pwsh` over `powershell`
47+
* @note It caches the path for the subsequent calls to this function
48+
*/
49+
export function getPowerShell() {
50+
if (powershell === undefined) {
51+
const maybePwsh = which.sync("pwsh", { nothrow: true })
52+
if (maybePwsh !== null) {
53+
powershell = maybePwsh
54+
}
55+
const maybePowerShell = which.sync("powershell", { nothrow: true })
56+
if (maybePowerShell !== null) {
57+
powershell = maybePowerShell
58+
}
59+
}
60+
if (powershell === undefined) {
61+
throw new Error("Could not find powershell")
62+
}
63+
return powershell
64+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist"
5+
},
6+
"include": ["./src"]
7+
}

0 commit comments

Comments
 (0)