Skip to content

Commit

Permalink
perf(publishing): publish a version of fse-cli without dev stuff
Browse files Browse the repository at this point in the history
fix #6
  • Loading branch information
atao60 committed Jan 25, 2021
1 parent 02484d0 commit 3872fad
Show file tree
Hide file tree
Showing 14 changed files with 461 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/*.json
**/*.md
README
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ typings/
# DynamoDB Local files
.dynamodb/

# npm package build
# npm package build & publish
dist
.build
.tmp-dir
publish

# misc
.follow-up
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ The main available scripts are:
- `npm run build` - create a production ready build,
- `npm run commit` - commit instead of `git commit`,
- `npm run release` - run test, lint and build before creating a new release version,
- `npm run cli:publish` - publish on npm registry instead of `npm publish`,
- `npm run clean` - remove temporary folders as dist, .build, ...
- `npm run refresh` - remove node modules, package-lock.json, dist, ... and re-installs upgraded dependencies,
- `npm run lint` - check of code,
Expand Down Expand Up @@ -283,7 +284,9 @@ Answer questions:
* Determine whether the commit is a BREAKING CHANGES or not (by answering `y` and fill up BREAKING CHANGES descriptions in the CLI).
* (Optional) Mention the issues in the [issue tracking system](https://en.wikipedia.org/wiki/Issue_tracking_system), here [Github issues](https://github.com/atao60/fse-cli/issues), (by answering `y` and fill up the issue descriptions in the CLI).


> Any change can be released and published as soon as commited. See [below](#publish).
But any uncommited changes will prevent a release.
On the other hand, a publishing can be done with uncommited changes, ignoring them.

### Pull Request

Expand All @@ -297,7 +300,7 @@ git branch ### checking if current user is in 'master' branch before creating a
git checkout -b my-branch
```

Do here the wanted changes
Do here the wanted changes.

```bash

Expand All @@ -322,6 +325,8 @@ To publish on [npm](https://www.npmjs.com/) public registry, you must be an admi
- the package on the [npm](https://www.npmjs.com/) public registry, ie [@atao60/fse-cli](https://www.npmjs.com/package/@atao60/fse-cli),
- the repository on [Github](https://github.com), ie [atao60/fse-cli](https://github.com/atao60/fse-cli).

Don't use `npm publish` but `npm run cli:publish`:

```bash

git checkout master
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Welcome to @atao/fse-cli

[![NPM](https://nodei.co/npm/@atao60/fse-cli.png?mini=true)](https://www.npmjs.com/package/@atao60/fse-cli)


<span style="font-size:3em;">🏗</span>A [CLI](https://en.wikipedia.org/wiki/Command-line_interface) for [fs-extra](https://github.com/jprichardson/node-fs-extra).
🏗A [CLI](https://en.wikipedia.org/wiki/Command-line_interface) for [fs-extra](https://github.com/jprichardson/node-fs-extra).

## 💡 Rational

Expand All @@ -14,6 +13,7 @@ Everyone needs simple file system operations like copy, remove, clean, ... that
There are many [Npm](https://www.npmjs.com/) packages that provide all or any of this:
- as an [API](https://en.wikipedia.org/wiki/Application_programming_interface) to be used as part of an application, but without associated [CLI](https://en.wikipedia.org/wiki/Command-line_interface),
- as [CLI](https://en.wikipedia.org/wiki/Command-line_interface) but in separate [Npm](https://www.npmjs.com/) packages such as [rimraf](https://www.npmjs.com/package/rimraf), [mkdirp](https://www.npmjs.com/package/mkdirp), [cpy-cli](https://www.npmjs.com/package/cpy-cli), ...
- as [CLI](https://en.wikipedia.org/wiki/Command-line_interface) but in separate [Npm](https://www.npmjs.com/) packages such as [del-cli](https://www.npmjs.com/package/del-cli), [rimraf](https://www.npmjs.com/package/rimraf), [make-dir-cli](https://www.npmjs.com/package/make-dir-cli), [mkdirp](https://www.npmjs.com/package/mkdirp), [cpy-cli](https://www.npmjs.com/package/cpy-cli), [move-file-cli](https://www.npmjs.com/package/move-file-cli)...
- or even as a full [shell](https://en.wikipedia.org/wiki/Shell_(computing)) with e.g. [shx](https://www.npmjs.com/package/shx) based on [shelljs](https://www.npmjs.com/package/shelljs), a [Unix shell](https://en.wikipedia.org/wiki/Unix_shell) commands for [Node.js](https://nodejs.org).

[This package](https://www.npmjs.com/package/@atao60/fse-cli) just provides many of them from a unique [CLI](https://en.wikipedia.org/wiki/Command-line_interface), without any pretention to be any kind of [shell](https://en.wikipedia.org/wiki/Shell_(computing)).
Expand All @@ -23,7 +23,7 @@ It is based on the `API` [Node.js: fs-extra](https://github.com/jprichardson/nod
> If an `API` is needed, use [Node.js: fs-extra](https://github.com/jprichardson/node-fs-extra), **not** [@atao60/fse-cli](https://www.npmjs.com/package/@atao60/fse-cli). If only because the latter embeds a `npm-shrinkwrap.json` expunged from dev dependencies.

The [available CLI commands](#-commands) are fully functional and tested. However it's still a work in progress:
The [available CLI commands](#🎹-commands) are fully functional and tested. However it's still a work in progress:
* Not all [fs-extra](https://github.com/jprichardson/node-fs-extra) functions are mapped yet. Please, feel free to open an [issue](https://github.com/atao60/fse-cli/issues) if there is something you would like supported.
* More tests to come, even if they will only concern the CLI part without overlapping [fs-extra](https://github.com/jprichardson/node-fs-extra)'s tests.

Expand Down
164 changes: 148 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,14 @@
"prerelease": "npm run unstaged:check && npm run fullcheck && npm run build && git add -A",
"release": "cross-env HUSKY_SKIP_HOOKS=1 standard-version -a",
"postrelease": "cross-env HUSKY_SKIP_HOOKS=1 git push --follow-tags",
"prepublishOnly": "npm run prepublish:build && npm run prepublish:pack",
"lint:quiet": "tsc --project src && eslint src/**/* test/**/* scripts/**/* --ext .js,.ts --quiet",
"lint:quiet": "tsc --project src && eslint src/**/* test/**/* scripts/**/* --quiet",
"lint:fix": "eslint --fix src/ test/ scripts/",
"lint": "tsc --project src && eslint src/**/* test/**/* scripts/**/* --ext .js,.ts",
"lint": "tsc --project src && eslint src/**/* test/**/* scripts/**/*",
"analyse": "npx pkgfiles && npm list",
"postpublish": "npx rimraf npm-shrinkwrap.json && npx move-file-cli package-lock.json.0 package-lock.json && npm ci",
"prepublish:build": "npm ci && npm run fullcheck && npm run build",
"prepublish:pack": "npx cpy-cli package-lock.json ./ --rename=package-lock.json.0 && npm dedupe && npm prune --production && npm shrinkwrap",
"cli:publish": "npm publish --access public"
"prepublishOnly": "npm run publish:build && npm run publish:pack",
"publish:build": "npm ci && npm run fullcheck && npm run build",
"publish:pack": "ts-node ./tools/prepublish '' '../..'",
"cli:publish": "npm publish ./publish --access public"
},
"keywords": [
"fse",
Expand Down Expand Up @@ -161,6 +160,9 @@
"@types/fs-extra": "^9.0.1",
"@types/graceful-fs": "^4.1.3",
"@types/inquirer": "^6.5.0",
"@types/klaw": "^3.0.1",
"@types/lodash": "^4.14.168",
"@types/micromatch": "^4.0.1",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.14",
"@types/supports-color": "^7.2.0",
Expand All @@ -179,6 +181,9 @@
"eslint-config-node": "^4.1.0",
"eslint-plugin-import": "^2.22.0",
"husky": "^4.2.5",
"klaw": "^3.0.0",
"lodash": "^4.17.20",
"micromatch": "^4.0.2",
"mocha": "^8.0.1",
"nodemon": "^2.0.4",
"standard-version": "^9.0.0",
Expand Down
2 changes: 2 additions & 0 deletions scripts/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Put in this folder 'scripts' only scripts written as ES6 modules.
Put other scripts in folder '../tools'.
20 changes: 15 additions & 5 deletions scripts/rmdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@
*
* As this script is supposed to remove `node_modules`, don't use ts-node or any
* dependencies (not even graceful-fs... or extra-fs!), as it'd block the script, even under Linux.
*
* fs.rmdirSync supports a recursive options since Node.js 12.10.0: we can't use it
* as long as we stay with engines.node >=10.15.3
*/
import { existsSync, lstatSync, readdirSync, rmdirSync, unlinkSync } from 'fs';
import { join } from 'path';
import { argv, env, exit } from 'process';
import { argv, env } from 'process';

const pathList = [...argv.slice(2)] || [env.PATHS] || ['node_modules/'];
const DEFAULT_PATH = './node_modules/';
const PATH_SEP = ':';

if (!pathList || pathList.length < 1) {
console.log("File/folder list is empty or not provided: nothing's done.");
exit(1);
const pathList = argv.slice(2).filter(a => a && a.trim()).map(a=> a.trim());

if(pathList.length < 1 && env.PATHS && env.PATHS.trim()) {
const extraPaths = env.EXTRA_PATHS.split(PATH_SEP).filter(a => a && a.trim()).map(a => a.trim());
pathList.push(...extraPaths);
}

if(pathList.length < 1) {
pathList.push(DEFAULT_PATH);
}

function deepDelete(paths) {
Expand Down
Loading

0 comments on commit 3872fad

Please sign in to comment.