# ai-install

> Say goodbye to `npm install`, no need `npm install`, throw away `npm install`.

Latest version **1.1.1** (published 2022-09-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install ai-install
pnpm add ai-install
yarn add ai-install
bun add ai-install
```

Provides the command `ai-install`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-09-01 |
| First published | 2022-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | lamianbu |
| Maintainers | lamianbu |
| Keywords | npx, ai-install, install |

## Links

- npm: https://www.npmjs.com/package/ai-install
- Repository: https://github.com/lamianbu/ai-install
- Homepage: https://github.com/lamianbu/ai-install#readme
- Issues: https://github.com/lamianbu/ai-install/issues
- npm.io page: https://npm.io/package/ai-install

## Recent versions

- 1.1.1 (latest) — 2022-09-01
- 1.1.0 — 2022-08-04
- 1.0.0 — 2022-08-02
- 0.0.5 — 2022-08-01
- 0.0.4 — 2022-08-01
- 0.0.3 — 2022-08-01
- 0.0.2 — 2022-08-01
- 0.0.1 — 2022-08-01

## README

# ai-install
Say goodbye to `npm install`, no need `npm install`, throw away `npm install`.
## example
In your project, 

1. add `npx -y ai-install` (npm>=7) to package.json->scripts->start/build.

   use `npx ai-install` (npm<=6).

```json
{
  "name": "ai-install-demo",
  "scripts": {
    "start": "npx -y ai-install && xxx serve --open",
    "build": "npx -y ai-install && xxx build"
  },
  "devDependencies": {
    "xxx": "x.y.z"
  }
}
```
2. add a new file npm-start.sh, the content is: 

```shell
npm start 
```
After `git clone`, just double click npm-start.sh to start, no typing command.

## because
```shell
npx -y ai-install
```
executing `npm install` if not installed.

npx run an arbitrary command from an npm package (either one installed locally, or fetched remotely).

## think
Does it save a second of typing `npm i`? no!

After the installation of `npm i`, it was not seamlessly connected to `npm start`, which wasted 10 ~ 60 seconds.

If you use `npx -y ai-install`, then `npm start` will likely start a minute earlier.

## yarn & pnpm
```shell
npx -y ai-install
```
In yarn project, auto executing `yarn install` if not installed.

In pnpm project, auto executing `pnpm install` if not installed.

## src
package.json defined a commond `ai-install`.
```json
{
  "name": "ai-install",
  "version": "1.0.0",
  "description": "Say goodbay to `npm install`, no need `npm install`, throw away `npm install`.",
  "main": "index.js",
  "bin": {
    "ai-install": "index.js"
  }
}
```
index.js executing `npm/yarm/pnpm install` if not installed.
```js
#!/usr/bin/env node

var fs = require('fs');
var child_process = require('child_process');

if (!fs.existsSync('node_modules')) {
  if(fs.existsSync('yarn.lock')){
    child_process.execSync('yarn install', { stdio: 'inherit' });
  } else if (fs.existsSync('pnpm-lock.yaml')){
    child_process.execSync('pnpm install', { stdio: 'inherit' });
  } else if (fs.existsSync('package-lock.json') || fs.existsSync('npm-shrinkwrap.json')){
    // 'npm ci' is faster than 'npm i'.
    child_process.execSync('npm ci', { stdio: 'inherit' });
  } else {
    child_process.execSync('npm i', { stdio: 'inherit' });
  }
}
```

---
_Source: https://npm.io/package/ai-install · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
