create-cubing-app 0.35.6-rc15 → 0.35.6-rc16
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/Makefile +18 -0
- package/bin/create-cubing-app.js +22 -76
- package/package.json +3 -3
- /package/{bin/src → src}/index.css +0 -0
- /package/{bin/src → src}/index.html +0 -0
- /package/{bin/src → src}/main.ts +0 -0
package/Makefile
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# This Makefile is a wrapper around the scripts from `package.json`.
|
|
2
|
+
# https://github.com/lgarron/Makefile-scripts
|
|
3
|
+
|
|
4
|
+
# Note: the first command becomes the default `make` target.
|
|
5
|
+
NPM_COMMANDS = build dev clean
|
|
6
|
+
|
|
7
|
+
.PHONY: $(NPM_COMMANDS)
|
|
8
|
+
$(NPM_COMMANDS):
|
|
9
|
+
npm run $@
|
|
10
|
+
|
|
11
|
+
# We write the npm commands to the top of the file above to make shell autocompletion work in more places.
|
|
12
|
+
DYNAMIC_NPM_COMMANDS = $(shell node -e 'console.log(Object.keys(require("./package.json").scripts).join(" "))')
|
|
13
|
+
UPDATE_MAKEFILE_SED_ARGS = "s/^NPM_COMMANDS = .*$$/NPM_COMMANDS = ${DYNAMIC_NPM_COMMANDS}/" Makefile
|
|
14
|
+
.PHONY: update-Makefile
|
|
15
|
+
update-Makefile:
|
|
16
|
+
if [ "$(shell uname -s)" = "Darwin" ] ; then sed -i "" ${UPDATE_MAKEFILE_SED_ARGS} ; fi
|
|
17
|
+
if [ "$(shell uname -s)" != "Darwin" ] ; then sed -i"" ${UPDATE_MAKEFILE_SED_ARGS} ; fi
|
|
18
|
+
|
|
1
19
|
.PHONY: publish
|
|
2
20
|
publish:
|
|
3
21
|
npm publish
|
package/bin/create-cubing-app.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { exec } from "child_process";
|
|
3
|
-
import {
|
|
3
|
+
import { exists } from "fs";
|
|
4
|
+
import { mkdir, readFile, stat, writeFile } from "fs/promises";
|
|
4
5
|
import { join } from "path";
|
|
5
6
|
import { exit, stderr } from "process";
|
|
7
|
+
import { promisify } from "util";
|
|
6
8
|
|
|
7
9
|
function execPromise(cmd, options) {
|
|
8
10
|
return new Promise((resolve, reject) => {
|
|
@@ -44,6 +46,15 @@ const packageRoot = join(".", packageName);
|
|
|
44
46
|
function packageRooted(path) {
|
|
45
47
|
return join(packageRoot, path);
|
|
46
48
|
}
|
|
49
|
+
|
|
50
|
+
// We could uses `stat` from `"fs/promises"`, but I'm not too enthused about
|
|
51
|
+
// catching an error in the "expected" path. So we use `exists`.
|
|
52
|
+
if (await promisify(exists)(packageRoot)) {
|
|
53
|
+
process.stderr.write(`Project already exists in the current folder: ${packageRoot}
|
|
54
|
+
Please select a different name (or delete the existing project folder).
|
|
55
|
+
`);
|
|
56
|
+
exit(1);
|
|
57
|
+
}
|
|
47
58
|
await mkdir(packageRoot);
|
|
48
59
|
|
|
49
60
|
const initialPackageJSON = {
|
|
@@ -63,95 +74,30 @@ const execOptions = {
|
|
|
63
74
|
cwd: packageRoot,
|
|
64
75
|
};
|
|
65
76
|
await mkdir(packageRooted("src"), { recursive: true });
|
|
66
|
-
async function transferFile(rootedPath
|
|
77
|
+
async function transferFile(rootedPath) {
|
|
78
|
+
const filePath = new URL(join("..", rootedPath), import.meta.url);
|
|
79
|
+
const contents = await readFile(filePath, "utf-8");
|
|
67
80
|
await writeFile(packageRooted(rootedPath), contents);
|
|
68
81
|
}
|
|
69
|
-
await transferFile(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<head>
|
|
75
|
-
<meta charset="utf8">
|
|
76
|
-
<title>My Cubing App</title>
|
|
77
|
-
<link rel="stylesheet" href="./index.css">
|
|
78
|
-
<!-- Note: the source file is \`main.ts\`, but here we use the transpiled file name it will have on the web server. -->
|
|
79
|
-
<script src="./main.js" type="module"></script>
|
|
80
|
-
</head>
|
|
81
|
-
|
|
82
|
-
<body>
|
|
83
|
-
<h1>My Cubing App</h1>
|
|
84
|
-
<twisty-player id="main-player"></twisty-player>
|
|
85
|
-
</body>
|
|
86
|
-
|
|
87
|
-
</html>
|
|
88
|
-
`,
|
|
89
|
-
);
|
|
90
|
-
await transferFile(
|
|
91
|
-
"src/main.ts",
|
|
92
|
-
`// Always keep the following line if you are using any twisty players on your page.
|
|
93
|
-
import "cubing/twisty";
|
|
94
|
-
// Use the following line for specific imports from \`cubing/twisty\`.
|
|
95
|
-
import { TwistyAlgViewer, type TwistyPlayer } from "cubing/twisty";
|
|
96
|
-
|
|
97
|
-
// Import from other modules as usual.
|
|
98
|
-
import { randomScrambleForEvent } from "cubing/scramble";
|
|
99
|
-
|
|
100
|
-
class App {
|
|
101
|
-
// Example of getting an element from the page.
|
|
102
|
-
twistyPlayer: TwistyPlayer = document.querySelector("#main-player")!;
|
|
103
|
-
// Example of creating a new element and adding it to the page.
|
|
104
|
-
twistyAlgViewer = document.body.appendChild(
|
|
105
|
-
new TwistyAlgViewer({ twistyPlayer: this.twistyPlayer })
|
|
106
|
-
);
|
|
107
|
-
constructor() {
|
|
108
|
-
this.updateScramble();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
async updateScramble() {
|
|
112
|
-
this.twistyPlayer.alg = await randomScrambleForEvent("333");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Make the app object available in the console for debugging.
|
|
117
|
-
// Try running: app.updateScramble()
|
|
118
|
-
globalThis.app = new App();
|
|
119
|
-
`,
|
|
120
|
-
);
|
|
121
|
-
await transferFile(
|
|
122
|
-
"src/index.css",
|
|
123
|
-
`/* Center everything on the page. */
|
|
124
|
-
html, body {
|
|
125
|
-
height: 100%;
|
|
126
|
-
margin: 0;
|
|
127
|
-
display: grid;
|
|
128
|
-
place-content: center;
|
|
129
|
-
gap: 1em;
|
|
130
|
-
font-family: sans-serif;
|
|
131
|
-
}
|
|
132
|
-
`,
|
|
133
|
-
);
|
|
134
|
-
await transferFile(
|
|
135
|
-
".gitignore",
|
|
136
|
-
`/dist
|
|
137
|
-
/node_modules
|
|
138
|
-
`,
|
|
139
|
-
);
|
|
82
|
+
await transferFile("src/index.html");
|
|
83
|
+
await transferFile("src/main.ts");
|
|
84
|
+
await transferFile("src/index.css");
|
|
85
|
+
await transferFile(".gitignore");
|
|
140
86
|
|
|
141
87
|
await execPromise("npm install --save cubing", execOptions);
|
|
142
88
|
await execPromise("npm install --save-dev barely-a-dev-server", execOptions);
|
|
143
89
|
|
|
144
|
-
console.log(`
|
|
90
|
+
console.log(`Your cubing app has been created.
|
|
91
|
+
To work on it, run:
|
|
145
92
|
|
|
146
93
|
cd ${packageRoot}
|
|
147
94
|
npm run dev
|
|
148
95
|
|
|
149
|
-
To create
|
|
96
|
+
To create an optimized build of your app that can be uploaded to a file server, run:
|
|
150
97
|
|
|
151
98
|
npm run build
|
|
152
99
|
|
|
153
100
|
When a new version of \`cubing.js\` is released in the future, you can upgrade using:
|
|
154
101
|
|
|
155
102
|
npm install cubing@latest
|
|
156
|
-
|
|
157
103
|
`);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cubing-app",
|
|
3
|
-
"version": "0.35.6-
|
|
3
|
+
"version": "0.35.6-rc16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": "./bin/create-cubing-app.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "node -e 'import(\"barely-a-dev-server\").then(s => s.barelyServe({entryRoot: \"./
|
|
8
|
-
"dev": "node -e 'import(\"barely-a-dev-server\").then(s => s.barelyServe({entryRoot: \"./
|
|
7
|
+
"build": "node -e 'import(\"barely-a-dev-server\").then(s => s.barelyServe({entryRoot: \"./src\", dev: false, outDir: \"dist/web\"}))' && echo '' && echo 'Your app has been built in: ./dist/web' && echo ''",
|
|
8
|
+
"dev": "node -e 'import(\"barely-a-dev-server\").then(s => s.barelyServe({entryRoot: \"./src\"}))'",
|
|
9
9
|
"clean": "rm -rf ./dist"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
File without changes
|
|
File without changes
|
/package/{bin/src → src}/main.ts
RENAMED
|
File without changes
|