@bivabdas/sharq 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -1
- package/bin/create-sharq.js +6 -2
- package/bin/sharq.js +6 -2
- package/lib/package-info.js +11 -2
- package/lib/scaffold.js +8 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
`sharq` is a minimal static rendering framework for landing pages and Markdown-driven blogs. It generates crawl-friendly HTML, keeps output on disk, and can scaffold a new site with a single command.
|
|
4
4
|
|
|
5
|
+
Published on npm as `@bivabdas/sharq`.
|
|
6
|
+
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
9
|
- Markdown posts with frontmatter
|
|
@@ -12,8 +14,22 @@
|
|
|
12
14
|
|
|
13
15
|
## Install
|
|
14
16
|
|
|
17
|
+
Create a new site:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @bivabdas/sharq create my-site
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Install globally:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g @bivabdas/sharq
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Install in an existing project:
|
|
30
|
+
|
|
15
31
|
```bash
|
|
16
|
-
npm install sharq
|
|
32
|
+
npm install @bivabdas/sharq
|
|
17
33
|
```
|
|
18
34
|
|
|
19
35
|
## CLI
|
package/bin/create-sharq.js
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { readPackageVersion } from "../lib/package-info.js";
|
|
5
|
+
import { readPackageName, readPackageVersion } from "../lib/package-info.js";
|
|
6
6
|
import { scaffoldProject } from "../lib/scaffold.js";
|
|
7
7
|
|
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
|
10
10
|
const packageRoot = path.resolve(__dirname, "..");
|
|
11
11
|
const projectName = process.argv[2];
|
|
12
|
-
const packageVersion = await
|
|
12
|
+
const [packageName, packageVersion] = await Promise.all([
|
|
13
|
+
readPackageName(packageRoot),
|
|
14
|
+
readPackageVersion(packageRoot)
|
|
15
|
+
]);
|
|
13
16
|
|
|
14
17
|
if (projectName === "--help" || projectName === "-h" || projectName === "help") {
|
|
15
18
|
console.log(`create-sharq v${packageVersion}
|
|
@@ -23,6 +26,7 @@ Usage:
|
|
|
23
26
|
const project = await scaffoldProject({
|
|
24
27
|
packageRoot,
|
|
25
28
|
frameworkVersion: `^${packageVersion}`,
|
|
29
|
+
frameworkPackageName: packageName,
|
|
26
30
|
projectName
|
|
27
31
|
});
|
|
28
32
|
|
package/bin/sharq.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { resolveConfig } from "../lib/config.js";
|
|
6
6
|
import { buildStaticSite } from "../lib/generator.js";
|
|
7
|
-
import { readPackageVersion } from "../lib/package-info.js";
|
|
7
|
+
import { readPackageName, readPackageVersion } from "../lib/package-info.js";
|
|
8
8
|
import { startServer } from "../lib/server.js";
|
|
9
9
|
import { scaffoldProject } from "../lib/scaffold.js";
|
|
10
10
|
|
|
@@ -12,7 +12,10 @@ const [, , command, projectName] = process.argv;
|
|
|
12
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
13
|
const __dirname = path.dirname(__filename);
|
|
14
14
|
const packageRoot = path.resolve(__dirname, "..");
|
|
15
|
-
const packageVersion = await
|
|
15
|
+
const [packageName, packageVersion] = await Promise.all([
|
|
16
|
+
readPackageName(packageRoot),
|
|
17
|
+
readPackageVersion(packageRoot)
|
|
18
|
+
]);
|
|
16
19
|
|
|
17
20
|
function printHelp() {
|
|
18
21
|
console.log(`sharq v${packageVersion}
|
|
@@ -43,6 +46,7 @@ if (!command || command === "dev" || command === "start") {
|
|
|
43
46
|
const project = await scaffoldProject({
|
|
44
47
|
packageRoot,
|
|
45
48
|
frameworkVersion: `^${packageVersion}`,
|
|
49
|
+
frameworkPackageName: packageName,
|
|
46
50
|
projectName
|
|
47
51
|
});
|
|
48
52
|
|
package/lib/package-info.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
async function readPackageJson(packageRoot) {
|
|
5
5
|
const packageJsonPath = path.join(packageRoot, "package.json");
|
|
6
|
-
|
|
6
|
+
return JSON.parse(await fs.readFile(packageJsonPath, "utf8"));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function readPackageVersion(packageRoot) {
|
|
10
|
+
const packageJson = await readPackageJson(packageRoot);
|
|
7
11
|
return packageJson.version;
|
|
8
12
|
}
|
|
13
|
+
|
|
14
|
+
export async function readPackageName(packageRoot) {
|
|
15
|
+
const packageJson = await readPackageJson(packageRoot);
|
|
16
|
+
return packageJson.name;
|
|
17
|
+
}
|
package/lib/scaffold.js
CHANGED
|
@@ -64,7 +64,7 @@ function resolveLocalDependencySpec(projectDir, packageRoot) {
|
|
|
64
64
|
return `file:${relativePath}`;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
async function writePackageJson(projectDir, projectName, frameworkDependency) {
|
|
67
|
+
async function writePackageJson(projectDir, projectName, frameworkPackageName, frameworkDependency) {
|
|
68
68
|
const packageJson = {
|
|
69
69
|
name: projectName,
|
|
70
70
|
version: "0.1.0",
|
|
@@ -76,7 +76,7 @@ async function writePackageJson(projectDir, projectName, frameworkDependency) {
|
|
|
76
76
|
build: "sharq build"
|
|
77
77
|
},
|
|
78
78
|
dependencies: {
|
|
79
|
-
|
|
79
|
+
[frameworkPackageName]: frameworkDependency
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
|
|
@@ -153,7 +153,12 @@ export async function scaffoldProject(options = {}) {
|
|
|
153
153
|
|
|
154
154
|
const templateDir = path.join(packageRoot, "scaffold", "template");
|
|
155
155
|
await copyDir(templateDir, projectDir);
|
|
156
|
-
await writePackageJson(
|
|
156
|
+
await writePackageJson(
|
|
157
|
+
projectDir,
|
|
158
|
+
answers.projectName,
|
|
159
|
+
options.frameworkPackageName || "@bivabdas/sharq",
|
|
160
|
+
frameworkDependency
|
|
161
|
+
);
|
|
157
162
|
await writeConfig(projectDir, answers);
|
|
158
163
|
await writeReadme(projectDir, answers);
|
|
159
164
|
|