create-nodality 1.0.0-beta.74 → 1.0.0-beta.76

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.
Files changed (2) hide show
  1. package/bin/index.js +15 -7
  2. package/package.json +2 -2
package/bin/index.js CHANGED
@@ -5,22 +5,28 @@ import { resolve, dirname } from "path";
5
5
  import { execSync } from "child_process";
6
6
  import { fileURLToPath } from "url";
7
7
 
8
+ // path to script itself /Users/fv/create/index.js
8
9
  const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = dirname(__filename);
10
+ const __dirname = dirname(__filename); // create part (folder name)
10
11
 
11
12
  function createProject(projectName) {
13
+ // process.cwd() = current working directory (where user is running the command from)
14
+ // /Users/fv/create/PROJECT_NAME
12
15
  const projectPath = resolve(process.cwd(), projectName);
13
16
 
17
+ // Check if it exists
14
18
  if (existsSync(projectPath)) {
15
19
  console.error(`Folder ${projectName} already exists.`);
16
20
  process.exit(1);
17
21
  }
18
22
 
23
+ // Make PROJECT_NAME directory
19
24
  mkdirSync(projectPath);
20
25
  const srcPath = resolve(projectPath, "src");
21
26
  mkdirSync(srcPath);
22
27
 
23
28
  // index.html with import map pointing "nodality" to bundled ES module
29
+ // module will be bundled in next steps
24
30
  const indexHtml = `
25
31
  <!DOCTYPE html>
26
32
  <html lang="en">
@@ -81,8 +87,8 @@ export default {
81
87
  mode: "production",
82
88
  entry: "nodality",
83
89
  output: {
84
- path: path.resolve(__dirname, "dist"),
85
- filename: "lib.bundle.js",
90
+ path: path.resolve(__dirname, "dist"), // get dist folder in the current directory
91
+ filename: "lib.bundle.js", // will produce curr_dir/dist/lib.bundle.js using webpack when run
86
92
  library: {
87
93
  type: "module",
88
94
  },
@@ -118,11 +124,11 @@ export default {
118
124
  version: "1.0.0",
119
125
  type: "module",
120
126
  scripts: {
121
- build: "webpack --config webpack.config.js",
127
+ build: "webpack --config webpack.config.js", // calls webpack
122
128
  start: "npx serve . -l 4000",
123
129
  },
124
130
  dependencies: {
125
- nodality: "^1.0.0-beta.74",
131
+ nodality: "^1.0.0-beta.76",
126
132
  },
127
133
  devDependencies: {
128
134
  webpack: "^5.0.0",
@@ -149,10 +155,12 @@ export default {
149
155
  console.log("\nUsage:\n");
150
156
  console.log(` cd ${projectName}`);
151
157
  console.log(" npm run build # Rebuild library bundle");
152
- console.log(" npm start # Serve on http://localhost:4000\n");
158
+ console.log(" npm start # Serve the project");
153
159
  }
160
+ // copy to create-nodality folder
154
161
 
155
- const args = process.argv.slice(2);
162
+ // get 3rd component from "args" /(<project-name>)
163
+ const args = process.argv.slice(2);
156
164
  if (!args[0]) {
157
165
  console.error("Usage: npm create nodality <project-name>");
158
166
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nodality",
3
- "version": "1.0.0-beta.74",
3
+ "version": "1.0.0-beta.76",
4
4
  "description": "Project scaffolding tool for Nodality library",
5
5
  "bin": {
6
6
  "create-nodality": "bin/index.js"
@@ -18,6 +18,6 @@
18
18
  "author": "Filip Vabrousek",
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "nodality": "^1.0.0-beta.74"
21
+ "nodality": "^1.0.0-beta.76"
22
22
  }
23
23
  }