Skip to content

Commit

Permalink
feat: rename folder from doc to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kathikraemer committed Feb 7, 2024
1 parent fd467d7 commit 1f2d85e
Show file tree
Hide file tree
Showing 29 changed files with 435 additions and 138 deletions.
44 changes: 24 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![Issues](https://img.shields.io/github/issues-raw/deven-org/documentation-skeleton.svg?maxAge=25000)](https://github.com/deven-org/documentation-skeleton/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/deven-org/documentation-skeleton.svg?style=flat)](https://github.com/deven-org/documentation-skeleton/pulls)
[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat)](https://github.com/deven-org/documentation-skeleton/blob/main/doc/CODEOFCONDUCT.md)
[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat)](https://github.com/deven-org/documentation-skeleton/blob/main/doc/CODE_OF_CONDUCT.md)
[![GitHub contributors](https://img.shields.io/github/contributors/deven-org/documentation-skeleton.svg?style=flat)](https://github.com/deven-org/documentation-skeleton/)
![Coverage](https://img.shields.io/badge/Code%20Coverage-83%25-success?style=flat)

Expand All @@ -13,21 +13,21 @@
## :information_source: Table of contents

- [Deven Documentation Skeleton](#deven-documentation-skeleton)
- [:information\_source: Table of contents](#information_source-table-of-contents)
- [:information_source: Table of contents](#information_source-table-of-contents)
- [:star: Introduction](#star-introduction)
- [Goals](#goals)
- [:file\_folder: Documentation Structure](#file_folder-documentation-structure)
- [:file_folder: Documentation Structure](#file_folder-documentation-structure)
- [Requirements](#requirements)
- [Installation](#installation)
- [:rocket: How to use it](#rocket-how-to-use-it)
- [1. Install](#1-install)
- [2. Check](#2-check)
- [3. Update](#3-update)
- [:white\_check\_mark: How to test](#white_check_mark-how-to-test)
- [:white_check_mark: How to test](#white_check_mark-how-to-test)
- [:v: Contribute](#v-contribute)
- [:bug: Bugs and Issues](#bug-bugs-and-issues)
- [:page\_facing\_up: License](#page_facing_up-license)
- [:green\_heart: Code of conduct](#green_heart-code-of-conduct)
- [:page_facing_up: License](#page_facing_up-license)
- [:green_heart: Code of conduct](#green_heart-code-of-conduct)

# :star: Introduction

Expand All @@ -46,15 +46,15 @@ The purpose of this "documentation skeleton" project is to provide a simple way
## :file_folder: Documentation Structure

.
└── src/doc
└── src/docs
└── README.md
└── ARCHITECTURE.md
└── CODEOFCONDUCT.md
└── CODE_OF_CONDUCT.md
└── CONTRIBUTE.md
└── DEPLOYMENT.md
└── GETSTARTED.md
└── GET_STARTED.md
└── GLOSSARY.md
└── PROJECTBACKGROUND.md
└── PROJECT_BACKGROUND.md
└── TESTING.md

## Requirements
Expand All @@ -75,10 +75,11 @@ The purpose of this "documentation skeleton" project is to provide a simple way
To install the package in your project follow these steps:

install the package:

```bash
npm install @deven-org/documentation-skeleton --save-dev
```

or

```bash
Expand Down Expand Up @@ -115,11 +116,11 @@ yarn doc:install
<summary>What to expect?</summary>
<br />

First of all a new folder will be created (`./doc`) containing all the skeleton chapters.
First of all a new folder will be created (`./docs`) containing all the skeleton chapters.
Then it will be generated a config (`./.deven-skeleton-install.config`) which will track the installed version.

If the `./doc` folder exists already, it will be renamed to `./_doc` and a new `doc` folder will be generated.
If both the `doc` folder and the `_doc` folder are existing, the script won't proceed until you don't delete one of them.
If the `./docs` folder exists already, it will be renamed to `./_docs_backup_please_rename` and a new `docs` folder will be generated.
If both the `docs` folder and the `_docs_backup_please_rename` folder are existing, the script won't proceed until you don't delete one of them.

If the `./.deven-skeleton-install.config` is already existing, the script will just stop. It means that the documentation skeleton has been already succesfully installed and there's no need to proceed with a new installation.

Expand All @@ -144,15 +145,18 @@ yarn doc:check
<br />

The tool will show the `diff` between the skeleton chapters and the chapters located in the local documentation folder.
If other files have been added to the `doc` folder, they will be ignored.
If other files have been added to the `docs` folder, they will be ignored.

The content of the chapters won't be analysed nor considered for this report.

</details>

### 3. Update

In case one or more chapters are missing in the local documentation folder, the command `update` will clone them into the `doc` folder.
In case a previous version that used the `doc` folder instead of `docs`, the command `update` will try to rename the folder if no other `docs` folder already exists. Otherwise an error will be shown and the process will be aborted.
Furthermore some of the files will be renamed: `CODEOFCONDUCT.md` to `CODE_OF_CONDUCT.md`, `GETSTARTED.md` to `GET_STARTED.md` and `PROJECTBACKGROUND.md` to `PROJECT_BACKGROUND.md`.

In case one or more chapters are missing in the local documentation folder, the command `update` will clone them into the `docs` folder.

```bash
npm run doc:update
Expand Down Expand Up @@ -180,21 +184,21 @@ If the local version is greater than the one of the installed packaged, the scri

# :white_check_mark: How to test

[Read more](./doc/TESTING.md)
[Read more](./docs/TESTING.md)

# :v: Contribute

[Read more](./doc/CONTRIBUTE.md)
[Read more](./docs/CONTRIBUTE.md)

# :bug: Bugs and Issues

If you would like to open an issue, you can gladly use [this page](https://git.sinnerschrader.com/deven/documentation-skeleton/-/issues).
But please, have a look at the [Contribute](./doc/CONTRIBUTE.md) page before filing a bug.
But please, have a look at the [Contribute](./docs/CONTRIBUTE.md) page before filing a bug.

# :page_facing_up: License

[MIT LICENCE](./LICENSE.md)

# :green_heart: Code of conduct

You can find the [Code of Conduct here](./doc/CODEOFCONDUCT.md)
You can find the [Code of Conduct here](./docs/CODE_OF_CONDUCT.md)
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions doc/CONTRIBUTE.md → docs/CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Welcome to our docs contributing guide <!-- omit in toc -->

Thank you for investing your time in contributing to our project! We sincerely appreciate it. :sparkles:.
Please, read our [Code of Conduct](./CODEOFCONDUCT.md) to keep our community approachable and respectable.
Please, read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable.

## Content

- [New contributor guide](#new-contributor-guide)
- [Getting started](#getting-started)
- [:file_folder: File Structure](#file_folder-file-structure)
- [Issues](#issues)
- [Create a new issue](#create-a-new-issue)
- [Create a new issue](#create-a-new-issue)
- [Solve an issue](#solve-an-issue)
- [Prerequisites](#prerequisites)
- [Commits](#commits)
Expand All @@ -33,7 +33,7 @@ To get an overview of the project, read the [README](../README.md). Here are som
└── __tests__ // Unit test (*.spec.ts)
└── commands // CLI's commands classes
└── shared // Global configuration and log messages
└── doc // the documentation skeleton
└── docs // the documentation skeleton
└── config // the configuration file blueprint
└── dist // build output
└── bin // cli entrypoint
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/TESTING.md → docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ beforeEach(() => {
mockLog = mockConsoleLog();
mockFs({
fake_test_folder: {},
"src/doc": mockFs.load(path.resolve("src/doc"), {
"src/docs": mockFs.load(path.resolve("src/docs"), {
lazy: false,
}),
"src/root": mockFs.load(path.resolve("src/root"), {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"files": [
"dist/",
"bin/",
"src/doc",
"src/docs",
"src/root",
"CHANGELOG.md",
"LICENSE",
Expand Down
26 changes: 21 additions & 5 deletions src/__tests__/check.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("deven-cli", () => {
mockLog = mockConsoleLog();
mockFs({
fake_test_folder: {},
"src/doc": mockFs.load(path.resolve("src/doc"), {
"src/docs": mockFs.load(path.resolve("src/docs"), {
lazy: false,
}),
"src/root": mockFs.load(path.resolve("src/root"), {
Expand Down Expand Up @@ -63,7 +63,7 @@ describe("deven-cli", () => {
expect(mockExit).toHaveBeenLastCalledWith(1);
});
it("shows a positive message if the documentation folder has been found", async () => {
fs.mkdirSync(check.docPath);
fs.mkdirSync(check.docsPath);
const info = jest.spyOn(logger, "info");
check.preliminaryCheck();
expect(info).toHaveBeenCalledWith(messages.check.checkFolderExist);
Expand All @@ -74,6 +74,22 @@ describe("deven-cli", () => {
expect(error).toHaveBeenCalledWith(messages.check.checkFolderNotExist);
expect(mockExit).toHaveBeenLastCalledWith(1);
});
it("shows a positive message if the outdated documentation folder has not been found", async () => {
fs.mkdirSync(check.outdatedDocPath);
const info = jest.spyOn(logger, "info");
check.preliminaryCheck();
expect(info).toHaveBeenCalledWith(
messages.check.checkOutdatedFolderNotExist
);
});
it("shows an error message if the outdated documentation folder has been found", async () => {
const error = jest.spyOn(logger, "error");
check.preliminaryCheck();
expect(error).toHaveBeenCalledWith(
messages.check.checkOutdatedFolderExist
);
expect(mockExit).toHaveBeenLastCalledWith(1);
});
it("shows a positive message if the readme file has been found", async () => {
fs.writeFileSync(check.readmePath, "");
const info = jest.spyOn(logger, "info");
Expand All @@ -88,21 +104,21 @@ describe("deven-cli", () => {
});

it("exit with code 0 if the preliminary checks are truthy", async () => {
fs.mkdirSync(check.docPath);
fs.mkdirSync(check.docsPath);
fs.writeFileSync(check.readmePath, "");
fs.writeFileSync(check.configFilePath, "");
check.run();
expect(mockExit).toHaveBeenLastCalledWith(0);
});

it("shows the header message ", async () => {
fs.mkdirSync(check.docPath);
fs.mkdirSync(check.docsPath);
fs.writeFileSync(check.readmePath, "");
fs.writeFileSync(check.configFilePath, "");
check.checkChapters();
expect(mockLog).toHaveBeenNthCalledWith(
1,
chalk.bold(messages.check.contentDocFolder.message)
chalk.bold(messages.check.contentDocsFolder.message)
);
});
});
Expand Down
42 changes: 28 additions & 14 deletions src/__tests__/command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import * as path from "path";
import * as fs from "fs-extra";
import { configuration } from "../shared/configuration";
import { Command } from "../commands/command";
import { logger } from "../Logger";
import mockFs from "mock-fs";
import {
mockProcessExit,
mockProcessStdout,
mockProcessStderr,
mockConsoleLog,
} from "jest-mock-process";
import { messages } from "../shared/messages";
import chalk from "chalk";

let mockExit: jest.SpyInstance;
let mockStdout: jest.SpyInstance;
Expand All @@ -34,7 +31,7 @@ describe("deven-cli", () => {
mockLog = mockConsoleLog();
mockFs({
fake_test_folder: {},
"src/doc": mockFs.load(path.resolve("src/doc"), {
"src/docs": mockFs.load(path.resolve("src/docs"), {
lazy: false,
}),
"src/root": mockFs.load(path.resolve("src/root"), {
Expand All @@ -50,14 +47,24 @@ describe("deven-cli", () => {
});

describe("command", () => {
it("provides the right doc path (<root>/doc)", async () => {
expect(command.docPath).toBe("fake_test_folder/doc");
it("getDocsFilePath returns the correct path", async () => {
expect(command.getDocsFilePath("test.md")).toBe(
"fake_test_folder/docs/test.md"
);
}),
it("provides the right docs path (<root>/docs)", async () => {
expect(command.docsPath).toBe("fake_test_folder/docs");
});
it("provides the right outdated doc path (<root>/doc)", async () => {
expect(command.outdatedDocPath).toBe("fake_test_folder/doc");
});
it("provides the right readme path (<root>/README.md)", async () => {
expect(command.readmePath).toBe("fake_test_folder/README.md");
});
it("provides the right doc backup path (<root>/_doc)", async () => {
expect(command.docBackupPath).toBe("fake_test_folder/_doc");
it("provides the right docs backup path (<root>/_docs_backup_please_rename)", async () => {
expect(command.docsBackupPath).toBe(
"fake_test_folder/_docs_backup_please_rename"
);
});
it("provides the right readme backup path (<root>/_README)", async () => {
expect(command.readmeBackupPath).toBe("fake_test_folder/_README.md");
Expand All @@ -77,18 +84,25 @@ describe("deven-cli", () => {
fs.writeFileSync(command.configFilePath, "");
expect(command.existsConfigFile).toBeTruthy();
});
it("return false when the outdated doc folder doesn't exist", async () => {
expect(command.existsOutdatedDocFolder).toBeFalsy();
});
it("return true when the outdated doc folder exists", async () => {
fs.mkdirSync(command.outdatedDocPath);
expect(command.existsOutdatedDocFolder).toBeTruthy();
});
it("return the list of all the available chapters (except the readme)", async () => {
expect(command.docSourceFiles.length).toBe(8);
expect(command.docsSourceFiles.length).toBe(8);
});
it("return the list of all local chapters (except the readme)", async () => {
fs.copySync(command.docSourcePath, command.docPath);
expect(command.docFiles.length).toBe(8);
fs.copySync(command.docsSourcePath, command.docsPath);
expect(command.docsFiles.length).toBe(8);
});
it("return the list of all the chapters", async () => {
fs.copySync(command.docSourcePath, command.docPath);
fs.copySync(command.docsSourcePath, command.docsPath);
expect(command.coverage).toBe(100);
fs.rmSync(path.join(command.docPath, "CONTRIBUTE.md"));
fs.rmSync(path.join(command.docPath, "TESTING.md"));
fs.rmSync(path.join(command.docsPath, "CONTRIBUTE.md"));
fs.rmSync(path.join(command.docsPath, "TESTING.md"));
expect(command.coverage).toBe(75);
});
});
Expand Down
20 changes: 10 additions & 10 deletions src/__tests__/install.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("deven-cli", () => {
mockLog = mockConsoleLog();
mockFs({
fake_test_folder: {},
"src/doc": mockFs.load(path.resolve("src/doc"), {
"src/docs": mockFs.load(path.resolve("src/docs"), {
lazy: false,
}),
"src/root": mockFs.load(path.resolve("src/root"), {
Expand All @@ -54,16 +54,16 @@ describe("deven-cli", () => {

describe("install", () => {
it("renames the folder if it already exists during the installation", async () => {
fs.writeFileSync(install.docPath, "");
fs.writeFileSync(install.docsPath, "");
await install.run();
expect(fs.existsSync(install.docBackupPath)).toBeTruthy();
expect(fs.existsSync(install.docsBackupPath)).toBeTruthy();
});

it("clones the source doc folder into the destination doc folder", async () => {
it("clones the source docs folder into the destination docs folder", async () => {
await install.run();
expect(fs.existsSync(install.docPath)).toBeTruthy();
expect(JSON.stringify(fs.readdirSync(install.docPath))).toBe(
JSON.stringify(fs.readdirSync(install.docSourcePath))
expect(fs.existsSync(install.docsPath)).toBeTruthy();
expect(JSON.stringify(fs.readdirSync(install.docsPath))).toBe(
JSON.stringify(fs.readdirSync(install.docsSourcePath))
);
});

Expand All @@ -84,9 +84,9 @@ describe("deven-cli", () => {
expect(error).toHaveBeenCalled();
});

it("fails the preliminary check because the doc and doc backup folder exist", async () => {
fs.mkdirSync(install.docPath);
fs.mkdirSync(install.docBackupPath);
it("fails the preliminary check because the docs and docs backup folder exist", async () => {
fs.mkdirSync(install.docsPath);
fs.mkdirSync(install.docsBackupPath);
const error = jest.spyOn(logger, "error");
await install.run();
expect(error).toHaveBeenCalledWith(messages.install.checkFolderExist);
Expand Down
Loading

0 comments on commit 1f2d85e

Please sign in to comment.