Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the utils functions to separate packages #114

Merged
merged 29 commits into from
Aug 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
46635fc
feat: add exec-powershell package
aminya Aug 7, 2022
4c866cd
fix: use exec-powershell in setup-cpp
aminya Aug 8, 2022
fe2db9d
feat: add sudo-tools package
aminya Aug 8, 2022
2996940
fix: use sudo-tools in setup-cpp
aminya Aug 8, 2022
bf519e6
fix: rename execSudo to execRoot and isRoot to isSudo
aminya Aug 8, 2022
860880c
feat: add isRoot function in addition to isSudo
aminya Aug 8, 2022
2cdfbab
fix: do not cache isSudo
aminya Aug 8, 2022
0d99c85
fix: do not assume that CI (e.g. Docker) is root
aminya Aug 8, 2022
e495d4d
fix: rename execRoot to execRootSync
aminya Aug 8, 2022
897c5f6
feat: add async execRoot
aminya Aug 8, 2022
92711bc
feat: add sync execPowershell
aminya Aug 8, 2022
b77e674
fix: rename sudo-tools to root-tools
aminya Aug 8, 2022
758bb59
docs: automatically create the readme for the packages
aminya Aug 8, 2022
277b6cc
feat: add extension-tools package
aminya Aug 8, 2022
41bcd6a
Revert "fix: do not assume that CI (e.g. Docker) is root"
aminya Aug 8, 2022
c5a2f11
fix: use extension-tools in setup-cpp
aminya Aug 8, 2022
88c2d1a
fix: use ci-detect instead of isCI
aminya Aug 8, 2022
f8515df
fix: set shell: true for execRoot
aminya Aug 8, 2022
3d08c16
fix: fix github-actions detection
aminya Aug 8, 2022
6dd9d76
fix: add types for escape-path-with-spaces
aminya Aug 8, 2022
a0ead74
fix: fix the root-tools folder name
aminya Aug 8, 2022
b4a8389
feat: add untildify-user package
aminya Aug 8, 2022
b38bf66
feat: add user-access package
aminya Aug 8, 2022
232af3c
fix: use is-url-online to validate the download links
aminya Aug 8, 2022
edc37d2
Revert "fix: use is-url-online to validate the download links"
aminya Aug 8, 2022
0bbdead
feat: use is-link-working to test the urls
aminya Aug 8, 2022
91ab4d1
fix: use is-link-working fork
aminya Aug 8, 2022
4d3cf92
feat: add get-works package to validate the URLs
aminya Aug 8, 2022
1df74e7
docs: add readme for get-works [skip ci]
aminya Aug 8, 2022
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,8 +11,7 @@ temp-*
*.tsbuildinfo

# Build directories
dist/
!./dist/
packages/*/dist/
.parcel-cache
exe/
*.log
2 changes: 2 additions & 0 deletions dist/actions_python.073441c2.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/actions_python.073441c2.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/actions_python.4e47ab32.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/actions_python.4e47ab32.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/setup_cpp.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/setup_cpp.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/setup_cpp.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/setup_cpp.mjs.map

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions packages/extension-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<h1 align="center">extension-tools</h1>
<p>
<a href="https://www.npmjs.com/package/extension-tools" target="_blank">
<img alt="Version" src="https://img.shields.io/npm/v/extension-tools.svg">
</a>
<a href="#" target="_blank">
<img alt="License: Apache--2.0" src="https://img.shields.io/badge/License-Apache--2.0-yellow.svg" />
</a>
</p>

> Tools for working with file extensions such as getting the binary and shell extension on different platforms.
## Install

```sh
npm install --save extension-tools
```

## Usage

<!-- INSERT GENERATED DOCS START -->

### `addBinExtension` (function)

Add bin extension to the given binary name.

**Parameters:**

- name (`string`) - The name you want to add the shell extension to
- win_ext (`string`) - `.exe` on Windows
- unix_ext (`string`) - `""` On unix.

**returns:** string

### `addShellExtension` (function)

Add native shell extension to the given name

**Parameters:**

- name (`string`) - The name you want to add the shell extension to
- win_ext (`string`) - `.bat` on Windows
- unix_ext (`string`) - `.sh` On unix.

**returns:** string

### `addShellHere` (function)

Prefix a `./` for unix shell and nothing for the cmd shell

**Parameters:**

- name (`string`)

**returns:** string

<!-- INSERT GENERATED DOCS END -->

## 🤝 Contributing

You can sponsor my work here:

https://github.com/sponsors/aminya

Pull requests, issues and feature requests are welcome.
See the [Contributing guide](https://github.com/aminya/setup-cpp/blob/master/CONTRIBUTING.md).
34 changes: 34 additions & 0 deletions packages/extension-tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "extension-tools",
"version": "1.0.0",
"description": "Tools for working with file extensions such as getting the binary and shell extension on different platforms.",
"homepage": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"source": "./src/index.ts",
"scripts": {
"build": "tsc"
},
"keywords": [
"extension",
"shell",
"bin",
"windows",
"sh",
"cmd",
"bat",
"exec",
"execa",
"spawn",
"system",
"unix",
"linux",
"github-actions",
"github",
"actions",
"gitlab",
"ci"
]
}
35 changes: 35 additions & 0 deletions packages/extension-tools/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Add bin extension to the given binary name.
*
* @param name The name you want to add the shell extension to
* @param win_ext `.exe` on Windows
* @param unix_ext `""` On unix.
*/
export function addBinExtension(name: string, win_ext = ".exe", unix_ext = "") {
if (process.platform === "win32") {
return `${name}${win_ext}`
}
return `${name}${unix_ext}`
}

/**
* Add native shell extension to the given name
*
* @param name The name you want to add the shell extension to
* @param win_ext `.bat` on Windows
* @param unix_ext `.sh` On unix.
*/
export function addShellExtension(name: string, win_ext = ".bat", unix_ext = ".sh") {
if (process.platform === "win32") {
return `${name}${win_ext}`
}
return `${name}${unix_ext}`
}

/** Prefix a `./` for unix shell and nothing for the cmd shell */
export function addShellHere(name: string) {
if (process.platform === "win32") {
return name
}
return `./${name}`
}
7 changes: 7 additions & 0 deletions packages/extension-tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["./src"]
}