@joystick.js/cli-canary 0.0.0-canary.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/.build/getFilesToBuild.js +38 -0
- package/.build/index.js +69 -0
- package/HMRNOTES.txt +23 -0
- package/README.md +7 -0
- package/_package.json +55 -0
- package/canary.js +12 -0
- package/dist/cli.js +69 -0
- package/dist/functions/build/getTarIgnoreList.js +25 -0
- package/dist/functions/build/index.js +54 -0
- package/dist/functions/create/buildPackageJSON.js +20 -0
- package/dist/functions/create/index.js +193 -0
- package/dist/functions/create/templates/api/index.js +4 -0
- package/dist/functions/create/templates/i18n/en-US.js +4 -0
- package/dist/functions/create/templates/index.client.js +7 -0
- package/dist/functions/create/templates/index.css +20 -0
- package/dist/functions/create/templates/index.html +23 -0
- package/dist/functions/create/templates/index.server.js +21 -0
- package/dist/functions/create/templates/public/apple-touch-icon-152x152.png +0 -0
- package/dist/functions/create/templates/public/favicon.ico +0 -0
- package/dist/functions/create/templates/public/manifest.json +25 -0
- package/dist/functions/create/templates/public/service-worker.js +32 -0
- package/dist/functions/create/templates/public/splash-screen-1024x1024.png +0 -0
- package/dist/functions/create/templates/settings.development.json +27 -0
- package/dist/functions/create/templates/ui/components/button/index.js +50 -0
- package/dist/functions/create/templates/ui/layouts/app/index.js +13 -0
- package/dist/functions/create/templates/ui/pages/error/index.js +31 -0
- package/dist/functions/create/templates/ui/pages/index/index.js +94 -0
- package/dist/functions/index.js +243 -0
- package/dist/functions/logout/index.js +20 -0
- package/dist/functions/push/checkIfProvisionAvailable.js +19 -0
- package/dist/functions/push/deploy/index.js +173 -0
- package/dist/functions/push/deploy/initial.js +100 -0
- package/dist/functions/push/deploy/version.js +100 -0
- package/dist/functions/push/domains.js +23 -0
- package/dist/functions/push/getAvailableCDN.js +23 -0
- package/dist/functions/push/getDeployment.js +41 -0
- package/dist/functions/push/getDeploymentSummary.js +38 -0
- package/dist/functions/push/getInstanceSizeRegions.js +37 -0
- package/dist/functions/push/getInstanceSizesForRegion.js +34 -0
- package/dist/functions/push/getProviderInstanceSizes.js +34 -0
- package/dist/functions/push/getProviderRegions.js +36 -0
- package/dist/functions/push/getProvidersWithConnectionStatus.js +20 -0
- package/dist/functions/push/getSessionToken.js +23 -0
- package/dist/functions/push/getUserFromSessionToken.js +37 -0
- package/dist/functions/push/index.js +210 -0
- package/dist/functions/push/loginToCheatCode.js +33 -0
- package/dist/functions/push/pingProvisionAPI.js +31 -0
- package/dist/functions/push/prompts.js +332 -0
- package/dist/functions/push/providerMap.js +11 -0
- package/dist/functions/push/providers.js +9 -0
- package/dist/functions/reset/index.js +0 -0
- package/dist/functions/reset/reset.js +127 -0
- package/dist/functions/start/bootstrapLayoutComponent.js +54 -0
- package/dist/functions/start/bootstrapPageComponent.js +51 -0
- package/dist/functions/start/buildFile.js +85 -0
- package/dist/functions/start/buildFiles.js +76 -0
- package/dist/functions/start/buildPlugins.js +183 -0
- package/dist/functions/start/checkIfPortAvailable.js +18 -0
- package/dist/functions/start/cleanup/index.js +18 -0
- package/dist/functions/start/databases/mongodb/availableQueryParameters.js +42 -0
- package/dist/functions/start/databases/mongodb/buildConnectionString.js +22 -0
- package/dist/functions/start/databases/mongodb/buildQueryParameters.js +14 -0
- package/dist/functions/start/databases/mongodb/checkConnection.js +38 -0
- package/dist/functions/start/databases/mongodb/connect.js +25 -0
- package/dist/functions/start/databases/mongodb/index.js +93 -0
- package/dist/functions/start/databases/postgresql/checkConnection.js +41 -0
- package/dist/functions/start/databases/postgresql/connect.js +27 -0
- package/dist/functions/start/databases/postgresql/index.js +106 -0
- package/dist/functions/start/databases/redis.js +0 -0
- package/dist/functions/start/databases/startProvider.js +16 -0
- package/dist/functions/start/fileDependencyMapper.js +22 -0
- package/dist/functions/start/filesToCopy.js +18 -0
- package/dist/functions/start/generateId.js +74 -0
- package/dist/functions/start/getCodependenciesForFile.js +64 -0
- package/dist/functions/start/getFilesToBuild.js +39 -0
- package/dist/functions/start/getProcessIdFromPort.js +60 -0
- package/dist/functions/start/hmrServer.js +66 -0
- package/dist/functions/start/index.js +535 -0
- package/dist/functions/start/isWindows.js +5 -0
- package/dist/functions/start/minifyFile.js +12 -0
- package/dist/functions/start/onWarn.js +63 -0
- package/dist/functions/start/readFileDependencyMap.js +16 -0
- package/dist/functions/start/removeDeletedDependenciesFromMap.js +18 -0
- package/dist/functions/start/setComponentId.js +46 -0
- package/dist/functions/start/updateFileMap.js +67 -0
- package/dist/functions/update/index.js +21 -0
- package/dist/functions/use/index.js +61 -0
- package/dist/index.js +8 -0
- package/dist/lib/CLILog.js +49 -0
- package/dist/lib/buildResolvePlugin.js +21 -0
- package/dist/lib/checkIfValidJSON.js +11 -0
- package/dist/lib/colorLog.js +7 -0
- package/dist/lib/getArgs.js +14 -0
- package/dist/lib/getCodeFrame.js +10 -0
- package/dist/lib/getOptions.js +15 -0
- package/dist/lib/getPlatformSafePath.js +7 -0
- package/dist/lib/getProvider.js +8 -0
- package/dist/lib/help.js +56 -0
- package/dist/lib/isObject.js +6 -0
- package/dist/lib/isValidJSONString.js +11 -0
- package/dist/lib/isWindows.js +5 -0
- package/dist/lib/killProcesses.js +0 -0
- package/dist/lib/loadSettings.js +33 -0
- package/dist/lib/loader.js +82 -0
- package/dist/lib/masterIgnoreList.js +16 -0
- package/dist/lib/nodeEnvironment.js +9 -0
- package/dist/lib/nodeEnvironments.js +8 -0
- package/dist/lib/parseCookiesFromLogin.js +18 -0
- package/dist/lib/rainbowRoad.js +7 -0
- package/dist/lib/readDirectorySync.js +14 -0
- package/dist/lib/regexes.js +12 -0
- package/dist/lib/replaceBackslashesWithForwardSlashes.js +8 -0
- package/dist/lib/replaceFileProtocol.js +8 -0
- package/dist/lib/serializeQueryParameters.js +8 -0
- package/dist/lib/settings.js +4 -0
- package/dist/lib/validateDatabasesFromSettings.js +34 -0
- package/dist/lib/wait.js +8 -0
- package/package.json +54 -0
- package/release.js +40 -0
- package/src/cli.js +88 -0
- package/src/functions/build/getTarIgnoreList.js +30 -0
- package/src/functions/build/index.js +63 -0
- package/src/functions/create/buildPackageJSON.js +18 -0
- package/src/functions/create/index.js +209 -0
- package/src/functions/create/templates/api/index.js +4 -0
- package/src/functions/create/templates/i18n/en-US.js +4 -0
- package/src/functions/create/templates/index.client.js +7 -0
- package/src/functions/create/templates/index.css +20 -0
- package/src/functions/create/templates/index.html +23 -0
- package/src/functions/create/templates/index.server.js +21 -0
- package/src/functions/create/templates/public/apple-touch-icon-152x152.png +0 -0
- package/src/functions/create/templates/public/favicon.ico +0 -0
- package/src/functions/create/templates/public/manifest.json +25 -0
- package/src/functions/create/templates/public/service-worker.js +32 -0
- package/src/functions/create/templates/public/splash-screen-1024x1024.png +0 -0
- package/src/functions/create/templates/settings.development.json +27 -0
- package/src/functions/create/templates/ui/components/button/index.js +50 -0
- package/src/functions/create/templates/ui/layouts/app/index.js +13 -0
- package/src/functions/create/templates/ui/pages/error/index.js +31 -0
- package/src/functions/create/templates/ui/pages/index/index.js +94 -0
- package/src/functions/index.js +243 -0
- package/src/functions/logout/index.js +20 -0
- package/src/functions/push/checkIfProvisionAvailable.js +20 -0
- package/src/functions/push/deploy/index.js +199 -0
- package/src/functions/push/deploy/initial.js +108 -0
- package/src/functions/push/deploy/version.js +108 -0
- package/src/functions/push/domains.js +23 -0
- package/src/functions/push/getAvailableCDN.js +27 -0
- package/src/functions/push/getDeployment.js +43 -0
- package/src/functions/push/getDeploymentSummary.js +39 -0
- package/src/functions/push/getInstanceSizeRegions.js +40 -0
- package/src/functions/push/getInstanceSizesForRegion.js +35 -0
- package/src/functions/push/getProviderInstanceSizes.js +35 -0
- package/src/functions/push/getProviderRegions.js +39 -0
- package/src/functions/push/getProvidersWithConnectionStatus.js +25 -0
- package/src/functions/push/getSessionToken.js +26 -0
- package/src/functions/push/getUserFromSessionToken.js +39 -0
- package/src/functions/push/index.js +245 -0
- package/src/functions/push/loginToCheatCode.js +34 -0
- package/src/functions/push/pingProvisionAPI.js +33 -0
- package/src/functions/push/prompts.js +276 -0
- package/src/functions/push/providerMap.js +8 -0
- package/src/functions/push/providers.js +6 -0
- package/src/functions/reset/index.js +0 -0
- package/src/functions/reset/reset.js +163 -0
- package/src/functions/start/bootstrapLayoutComponent.js +57 -0
- package/src/functions/start/bootstrapPageComponent.js +54 -0
- package/src/functions/start/buildFile.js +97 -0
- package/src/functions/start/buildFiles.js +101 -0
- package/src/functions/start/buildPlugins.js +215 -0
- package/src/functions/start/checkIfPortAvailable.js +21 -0
- package/src/functions/start/cleanup/index.js +23 -0
- package/src/functions/start/databases/mongodb/availableQueryParameters.js +39 -0
- package/src/functions/start/databases/mongodb/buildConnectionString.js +28 -0
- package/src/functions/start/databases/mongodb/buildQueryParameters.js +15 -0
- package/src/functions/start/databases/mongodb/checkConnection.js +40 -0
- package/src/functions/start/databases/mongodb/connect.js +25 -0
- package/src/functions/start/databases/mongodb/index.js +108 -0
- package/src/functions/start/databases/postgresql/checkConnection.js +43 -0
- package/src/functions/start/databases/postgresql/connect.js +27 -0
- package/src/functions/start/databases/postgresql/index.js +127 -0
- package/src/functions/start/databases/redis.js +0 -0
- package/src/functions/start/databases/startProvider.js +15 -0
- package/src/functions/start/fileDependencyMapper.js +24 -0
- package/src/functions/start/filesToCopy.js +15 -0
- package/src/functions/start/generateId.js +73 -0
- package/src/functions/start/getCodependenciesForFile.js +84 -0
- package/src/functions/start/getFilesToBuild.js +49 -0
- package/src/functions/start/getProcessIdFromPort.js +92 -0
- package/src/functions/start/hmrServer.js +78 -0
- package/src/functions/start/index.js +688 -0
- package/src/functions/start/isWindows.js +3 -0
- package/src/functions/start/minifyFile.js +10 -0
- package/src/functions/start/onWarn.js +68 -0
- package/src/functions/start/readFileDependencyMap.js +19 -0
- package/src/functions/start/removeDeletedDependenciesFromMap.js +19 -0
- package/src/functions/start/setComponentId.js +58 -0
- package/src/functions/start/updateFileMap.js +100 -0
- package/src/functions/update/index.js +20 -0
- package/src/functions/use/index.js +62 -0
- package/src/index.js +13 -0
- package/src/lib/CLILog.js +40 -0
- package/src/lib/buildResolvePlugin.js +32 -0
- package/src/lib/checkIfValidJSON.js +8 -0
- package/src/lib/colorLog.js +5 -0
- package/src/lib/getArgs.js +14 -0
- package/src/lib/getCodeFrame.js +8 -0
- package/src/lib/getOptions.js +12 -0
- package/src/lib/getPlatformSafePath.js +6 -0
- package/src/lib/getProvider.js +5 -0
- package/src/lib/help.js +56 -0
- package/src/lib/isObject.js +3 -0
- package/src/lib/isValidJSONString.js +8 -0
- package/src/lib/isWindows.js +3 -0
- package/src/lib/killProcesses.js +5 -0
- package/src/lib/loadSettings.js +40 -0
- package/src/lib/loader.js +94 -0
- package/src/lib/masterIgnoreList.js +13 -0
- package/src/lib/nodeEnvironment.js +6 -0
- package/src/lib/nodeEnvironments.js +8 -0
- package/src/lib/parseCookiesFromLogin.js +21 -0
- package/src/lib/rainbowRoad.js +5 -0
- package/src/lib/readDirectorySync.js +13 -0
- package/src/lib/regexes.js +5 -0
- package/src/lib/replaceBackslashesWithForwardSlashes.js +8 -0
- package/src/lib/replaceFileProtocol.js +8 -0
- package/src/lib/serializeQueryParameters.js +5 -0
- package/src/lib/settings.js +1 -0
- package/src/lib/validateDatabasesFromSettings.js +37 -0
- package/src/lib/wait.js +5 -0
- package/storage/.verdaccio-db.json +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
|
|
4
|
+
const getFileListFromPath = (directoryPath = '', files = []) => {
|
|
5
|
+
const filesInDirectory = fs.readdirSync(directoryPath);
|
|
6
|
+
const filesWithDirectoryPathPrefix = filesInDirectory.map((filePathInDirectory = '') => {
|
|
7
|
+
return join(directoryPath, filePathInDirectory);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
files.push(...filesWithDirectoryPathPrefix);
|
|
11
|
+
|
|
12
|
+
filesWithDirectoryPathPrefix.forEach((filePathWithDirectoryPrefix = '') => {
|
|
13
|
+
const pathIsDirectory = fs.statSync(filePathWithDirectoryPrefix).isDirectory();
|
|
14
|
+
|
|
15
|
+
if (pathIsDirectory) {
|
|
16
|
+
getFileListFromPath(filePathWithDirectoryPrefix, files);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return files;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default () => {
|
|
24
|
+
const files = getFileListFromPath("./src");
|
|
25
|
+
|
|
26
|
+
const filteredFiles = files.filter((path) => {
|
|
27
|
+
return (
|
|
28
|
+
!fs.lstatSync(path).isDirectory() &&
|
|
29
|
+
!["node_modules", "src/lib/rollup.config.js", ".DS_Store"].some(
|
|
30
|
+
(excludedPath) => {
|
|
31
|
+
return path.includes(excludedPath);
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return filteredFiles;
|
|
38
|
+
};
|
package/.build/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import esbuild from "esbuild";
|
|
4
|
+
import child_process from 'child_process';
|
|
5
|
+
import getFilesToBuild from "./getFilesToBuild.js";
|
|
6
|
+
import getPlatformSafePath from "../src/lib/getPlatformSafePath.js";
|
|
7
|
+
|
|
8
|
+
const buildFile = (fileToBuild) => {
|
|
9
|
+
const [_, file] = fileToBuild.split(getPlatformSafePath("src/"));
|
|
10
|
+
return esbuild
|
|
11
|
+
.build({
|
|
12
|
+
entryPoints: [`src/${file}`],
|
|
13
|
+
bundle: false,
|
|
14
|
+
outfile: `./dist/${file}`,
|
|
15
|
+
platform: "node",
|
|
16
|
+
format: "esm",
|
|
17
|
+
minify: false,
|
|
18
|
+
plugins: [],
|
|
19
|
+
})
|
|
20
|
+
.catch((error) => {
|
|
21
|
+
console.log(error);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const buildFiles = (filesToBuild = []) => {
|
|
26
|
+
return Promise.all(filesToBuild.map((file) => buildFile(file.path)));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const copyFiles = (filesToCopy = []) => {
|
|
30
|
+
filesToCopy.forEach((fileToCopy) => {
|
|
31
|
+
const [_, file] = fileToCopy.path.split(getPlatformSafePath("src/"));
|
|
32
|
+
fs.mkdir(`./dist/${path.dirname(file)}`, { recursive: true }, (error) => {
|
|
33
|
+
if (error) {
|
|
34
|
+
console.warn(error);
|
|
35
|
+
}
|
|
36
|
+
fs.writeFileSync(`./dist/${file}`, fs.readFileSync(getPlatformSafePath(`src/${file}`)));
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const filesToBuild = getFilesToBuild();
|
|
42
|
+
|
|
43
|
+
const files = filesToBuild.map((path) => {
|
|
44
|
+
let target = "esm";
|
|
45
|
+
|
|
46
|
+
const copyPaths = [
|
|
47
|
+
getPlatformSafePath("create/templates")
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const isCopyPath = copyPaths.some((copyPath) => {
|
|
51
|
+
return path.includes(copyPath);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (isCopyPath) {
|
|
55
|
+
target = "copy";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
path,
|
|
60
|
+
target,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (fs.existsSync('dist')) {
|
|
65
|
+
child_process.execSync('rm -rf ./dist');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
copyFiles(files.filter(({ target }) => target === "copy"));
|
|
69
|
+
buildFiles(files.filter(({ target }) => target !== "copy"));
|
package/HMRNOTES.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
cli/buildFiles:
|
|
2
|
+
|
|
3
|
+
- Keep track of files changed
|
|
4
|
+
- Let restartApplicationProcess handle call to HMR clients. This way we can guarantee everything is ready AND we only fire the HMR call ONCE.
|
|
5
|
+
|
|
6
|
+
cli/hmrServer:
|
|
7
|
+
|
|
8
|
+
- [x] Keep track of connections on the process object.
|
|
9
|
+
|
|
10
|
+
node/hmr/client:
|
|
11
|
+
|
|
12
|
+
- When a message comes in, detect the file type
|
|
13
|
+
- Any JS files should trigger a re-mount
|
|
14
|
+
- Any CSS should be handled in the same way as before
|
|
15
|
+
- Any HTML/settings should be handled in the same way as before
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
Other stuff:
|
|
20
|
+
|
|
21
|
+
- Clean up get path variations so it doesn't include generics like "index" for index.server.js, etc.
|
|
22
|
+
|
|
23
|
+
- Look at getCodependenciesForFile and make sure you're not over-scoped to other files.
|
package/README.md
ADDED
package/_package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@joystick.js/cli",
|
|
3
|
+
"version": "1.0.0-beta.71",
|
|
4
|
+
"developmentVersion": "1.0.0-beta.1695",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "CLI for the Joystick JavaScript framework.",
|
|
7
|
+
"main": "development.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"joystick": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "node .build/index.js",
|
|
13
|
+
"canary:release": "export NODE_ENV=development && npm run build && node canary.js",
|
|
14
|
+
"production:release": "export NODE_ENV=production && npm run build && node release.js",
|
|
15
|
+
"win:development:release": "SET NODE_ENV=development&& npm run build && node release.js",
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"author": "",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"cross-env": "^7.0.3",
|
|
23
|
+
"semver": "^7.3.5"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@babel/code-frame": "^7.15.8",
|
|
27
|
+
"acorn": "^8.5.0",
|
|
28
|
+
"ascii-table": "^0.0.9",
|
|
29
|
+
"chalk": "^4.1.2",
|
|
30
|
+
"chokidar": "^3.5.2",
|
|
31
|
+
"command-exists": "^1.2.9",
|
|
32
|
+
"cross-port-killer": "^1.4.0",
|
|
33
|
+
"currency-formatter": "^1.5.9",
|
|
34
|
+
"esbuild": "^0.17.19",
|
|
35
|
+
"esbuild-plugin-svg": "^0.1.0",
|
|
36
|
+
"form-data": "^4.0.0",
|
|
37
|
+
"fs-extra": "^10.0.0",
|
|
38
|
+
"inquirer": "^8.2.0",
|
|
39
|
+
"kill-port-process": "^3.1.0",
|
|
40
|
+
"lodash": "^4.17.21",
|
|
41
|
+
"mongo-uri-tool": "^1.0.1",
|
|
42
|
+
"mongodb": "^4.1.3",
|
|
43
|
+
"netstats": "^0.0.6",
|
|
44
|
+
"node-fetch": "^3.2.0",
|
|
45
|
+
"node-watch": "^0.7.2",
|
|
46
|
+
"pg": "^8.7.3",
|
|
47
|
+
"port-pid": "^0.0.7",
|
|
48
|
+
"ps-node": "^0.1.6",
|
|
49
|
+
"replace-in-files": "^3.0.0",
|
|
50
|
+
"selective-whitespace": "^1.0.4",
|
|
51
|
+
"systeminformation": "^5.11.0",
|
|
52
|
+
"ws": "^8.2.3",
|
|
53
|
+
"xmlhttprequest": "^1.8.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/canary.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import child_process from 'child_process';
|
|
3
|
+
|
|
4
|
+
fs.renameSync('package.json', '_package.json');
|
|
5
|
+
fs.renameSync('canary.json', 'package.json');
|
|
6
|
+
|
|
7
|
+
child_process.execSync('npm version prerelease --preid=canary');
|
|
8
|
+
|
|
9
|
+
child_process.execSync('npm publish --access=public');
|
|
10
|
+
|
|
11
|
+
fs.renameSync('package.json', 'canary.json');
|
|
12
|
+
fs.renameSync('_package.json', 'package.json');
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import help from "./lib/help.js";
|
|
3
|
+
import functions from "./functions/index.js";
|
|
4
|
+
import getArgs from "./lib/getArgs.js";
|
|
5
|
+
import getOptions from "./lib/getOptions.js";
|
|
6
|
+
const functionNames = Object.keys(functions);
|
|
7
|
+
const functionsCalled = process.argv.filter((arg) => functionNames.includes(arg));
|
|
8
|
+
const showHelp = process.argv.some((arg) => ["-h", "--help"].includes(arg));
|
|
9
|
+
if (showHelp || functionsCalled.length === 0) {
|
|
10
|
+
help();
|
|
11
|
+
process.exit(0);
|
|
12
|
+
}
|
|
13
|
+
if (functionsCalled.length > 1) {
|
|
14
|
+
console.log(chalk.red("Only one function can be called at a time."));
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
if (functionsCalled.includes("build")) {
|
|
18
|
+
const args = getArgs(functions.build.args);
|
|
19
|
+
const options = getOptions(functions.build.options);
|
|
20
|
+
if (functions.build.function && typeof functions.build.function === "function") {
|
|
21
|
+
functions.build.function(args, options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (functionsCalled.includes("create")) {
|
|
25
|
+
const args = getArgs(functions.create.args);
|
|
26
|
+
const options = getOptions(functions.create.options);
|
|
27
|
+
if (!args.name) {
|
|
28
|
+
console.log(chalk.red("Must pass a <name> for your app to joystick create. Run joystick --help for examples."));
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
if (functions.create.function && typeof functions.create.function === "function") {
|
|
32
|
+
functions.create.function(args, options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (functionsCalled.includes("logout")) {
|
|
36
|
+
const args = getArgs(functions.logout.args);
|
|
37
|
+
const options = getOptions(functions.logout.options);
|
|
38
|
+
if (functions.logout.function && typeof functions.logout.function === "function") {
|
|
39
|
+
functions.logout.function(args, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (functionsCalled.includes("push")) {
|
|
43
|
+
const args = getArgs(functions.push.args);
|
|
44
|
+
const options = getOptions(functions.push.options);
|
|
45
|
+
if (functions.push.function && typeof functions.push.function === "function") {
|
|
46
|
+
functions.push.function(args, options);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (functionsCalled.includes("start")) {
|
|
50
|
+
const args = getArgs(functions.start.args);
|
|
51
|
+
const options = getOptions(functions.start.options);
|
|
52
|
+
if (functions.start.function && typeof functions.start.function === "function") {
|
|
53
|
+
functions.start.function(args, options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (functionsCalled.includes("update")) {
|
|
57
|
+
const args = getArgs(functions.update.args);
|
|
58
|
+
const options = getOptions(functions.update.options);
|
|
59
|
+
if (functions.update.function && typeof functions.update.function === "function") {
|
|
60
|
+
functions.update.function(args, options);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (functionsCalled.includes("use")) {
|
|
64
|
+
const args = getArgs(functions.use.args);
|
|
65
|
+
const options = getOptions(functions.use.options);
|
|
66
|
+
if (functions.use.function && typeof functions.use.function === "function") {
|
|
67
|
+
functions.use.function(args, options);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import masterIgnoreList from "../../lib/masterIgnoreList.js";
|
|
3
|
+
var getTarIgnoreList_default = (excludedPaths = []) => {
|
|
4
|
+
const gitignore = fs.existsSync(".gitignore") ? fs.readFileSync(".gitignore", "utf-8") : "";
|
|
5
|
+
const gitignoreFiles = gitignore?.split("\n")?.filter((file) => {
|
|
6
|
+
return !file?.includes("#") && file?.trim() !== "";
|
|
7
|
+
});
|
|
8
|
+
const ignoreFiles = [
|
|
9
|
+
...gitignoreFiles,
|
|
10
|
+
...excludedPaths,
|
|
11
|
+
...(masterIgnoreList || [])?.map((ignore) => {
|
|
12
|
+
return `${process.cwd()}/./${ignore}`;
|
|
13
|
+
}),
|
|
14
|
+
"*.tar",
|
|
15
|
+
"*.tar.gz",
|
|
16
|
+
"*.tar.xz"
|
|
17
|
+
]?.filter((item, itemIndex, array) => {
|
|
18
|
+
return array.indexOf(item) === itemIndex;
|
|
19
|
+
});
|
|
20
|
+
const excludeList = `{${ignoreFiles?.map((ignoreFile) => `"${ignoreFile}"`).join(",")}}`;
|
|
21
|
+
return excludeList;
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
getTarIgnoreList_default as default
|
|
25
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import child_process from "child_process";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import Loader from "../../lib/loader.js";
|
|
4
|
+
import getFilesToBuild from "../start/getFilesToBuild.js";
|
|
5
|
+
import buildFiles from "../start/buildFiles.js";
|
|
6
|
+
import CLILog from "../../lib/CLILog.js";
|
|
7
|
+
import getTarIgnoreList from "./getTarIgnoreList.js";
|
|
8
|
+
import loadSettings from "../../lib/loadSettings.js";
|
|
9
|
+
var build_default = async (args = {}, options = {}) => {
|
|
10
|
+
if (!options?.type) {
|
|
11
|
+
CLILog("Must pass a type for your build.", {
|
|
12
|
+
level: "danger",
|
|
13
|
+
docs: "https://cheatcode.co/docs/joystick/cli#build"
|
|
14
|
+
});
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
console.log("");
|
|
18
|
+
const loader = new Loader({
|
|
19
|
+
padding: options?.isDeploy ? " " : "",
|
|
20
|
+
defaultMessage: "Building app..."
|
|
21
|
+
});
|
|
22
|
+
loader.text("Building app...");
|
|
23
|
+
const environment = options?.environment || "production";
|
|
24
|
+
const settings = !options?.continuousIntegration ? await loadSettings(environment) : null;
|
|
25
|
+
const filesToBuild = getFilesToBuild(settings?.config?.build?.excludedPaths);
|
|
26
|
+
const outputPath = ".build";
|
|
27
|
+
const outputPathForBuildType = options?.type === "tar" ? `${outputPath}/.tar` : outputPath;
|
|
28
|
+
await buildFiles(
|
|
29
|
+
filesToBuild,
|
|
30
|
+
outputPathForBuildType,
|
|
31
|
+
// NOTE: Treat standalone builds as being for production by default.
|
|
32
|
+
environment
|
|
33
|
+
).catch((error) => {
|
|
34
|
+
console.warn(error);
|
|
35
|
+
});
|
|
36
|
+
if (options?.type === "tar") {
|
|
37
|
+
const ignoreList = getTarIgnoreList(settings?.config?.build?.excludedPaths);
|
|
38
|
+
console.log(ignoreList);
|
|
39
|
+
child_process.execSync(
|
|
40
|
+
`cd ${outputPath}/.tar && tar -cf ../build.tar.xz --exclude=${ignoreList} .`
|
|
41
|
+
);
|
|
42
|
+
child_process.execSync(`cd ${outputPath} && rm -rf .tar`);
|
|
43
|
+
}
|
|
44
|
+
loader.stable("");
|
|
45
|
+
loader.stop();
|
|
46
|
+
console.log(
|
|
47
|
+
chalk.greenBright(`App built as ${options?.type} to ${outputPath}!
|
|
48
|
+
`)
|
|
49
|
+
);
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
};
|
|
52
|
+
export {
|
|
53
|
+
build_default as default
|
|
54
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var buildPackageJSON_default = (projectName = "") => {
|
|
2
|
+
const packageJSON = {
|
|
3
|
+
type: "module",
|
|
4
|
+
name: projectName,
|
|
5
|
+
version: "1.0.0",
|
|
6
|
+
description: "",
|
|
7
|
+
main: "index.js",
|
|
8
|
+
scripts: {
|
|
9
|
+
start: "joystick start",
|
|
10
|
+
test: 'echo "Error: no test specified" && exit 1'
|
|
11
|
+
},
|
|
12
|
+
keywords: [],
|
|
13
|
+
author: "",
|
|
14
|
+
license: "ISC"
|
|
15
|
+
};
|
|
16
|
+
return JSON.stringify(packageJSON, null, 2);
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
buildPackageJSON_default as default
|
|
20
|
+
};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { dirname } from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { exec } from "child_process";
|
|
6
|
+
import buildPackageJSON from "./buildPackageJSON.js";
|
|
7
|
+
import Loader from "../../lib/loader.js";
|
|
8
|
+
const npmRegistry = process.env.NODE_ENV === "development" ? "--registry http://localhost:4873" : "";
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
const createFiles = (projectName, files = []) => {
|
|
12
|
+
files.forEach(({ name, content }) => {
|
|
13
|
+
fs.writeFileSync(`./${projectName}/${name}`, content);
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const createFolders = (projectName, folders = []) => {
|
|
17
|
+
folders.forEach((folder) => {
|
|
18
|
+
fs.mkdirSync(`./${projectName}/${folder}`);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const createPackageJSON = (projectName = "") => {
|
|
22
|
+
fs.writeFileSync(
|
|
23
|
+
`./${projectName}/package.json`,
|
|
24
|
+
buildPackageJSON(projectName)
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const createJoystickFolder = (projectName = "") => {
|
|
28
|
+
fs.mkdirSync(`./${projectName}/.joystick`);
|
|
29
|
+
fs.mkdirSync(`./${projectName}/.joystick/build`);
|
|
30
|
+
};
|
|
31
|
+
const createProjectFolder = (projectName = "") => {
|
|
32
|
+
return fs.mkdirSync(`./${projectName}`);
|
|
33
|
+
};
|
|
34
|
+
const checkIfProjectExists = (projectName = "") => {
|
|
35
|
+
return fs.existsSync(`./${projectName}`);
|
|
36
|
+
};
|
|
37
|
+
var create_default = (args = {}) => {
|
|
38
|
+
try {
|
|
39
|
+
process.loader = new Loader({ defaultMessage: "Starting app..." });
|
|
40
|
+
process.loader.text("Creating app...");
|
|
41
|
+
const projectName = args?.name;
|
|
42
|
+
const projectAlreadyExists = checkIfProjectExists(projectName);
|
|
43
|
+
if (projectAlreadyExists) {
|
|
44
|
+
console.log(
|
|
45
|
+
chalk.red(
|
|
46
|
+
`A folder with the name ${projectName} already exists. Please choose a different name and try again.`
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
createProjectFolder(projectName);
|
|
52
|
+
createJoystickFolder(projectName);
|
|
53
|
+
createPackageJSON(projectName);
|
|
54
|
+
createFolders(projectName, [
|
|
55
|
+
"api",
|
|
56
|
+
"i18n",
|
|
57
|
+
"ui",
|
|
58
|
+
"ui/components",
|
|
59
|
+
"ui/components/button",
|
|
60
|
+
"ui/layouts",
|
|
61
|
+
"ui/layouts/app",
|
|
62
|
+
"ui/pages",
|
|
63
|
+
"ui/pages/error",
|
|
64
|
+
"ui/pages/index",
|
|
65
|
+
"lib",
|
|
66
|
+
"public"
|
|
67
|
+
]);
|
|
68
|
+
createFiles(projectName, [
|
|
69
|
+
{
|
|
70
|
+
name: "api/index.js",
|
|
71
|
+
content: fs.readFileSync(
|
|
72
|
+
`${__dirname}/templates/api/index.js`,
|
|
73
|
+
"utf-8"
|
|
74
|
+
)
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "i18n/en-US.js",
|
|
78
|
+
content: fs.readFileSync(
|
|
79
|
+
`${__dirname}/templates/i18n/en-US.js`,
|
|
80
|
+
"utf-8"
|
|
81
|
+
)
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "public/apple-touch-icon-152x152.png",
|
|
85
|
+
content: fs.readFileSync(
|
|
86
|
+
`${__dirname}/templates/public/apple-touch-icon-152x152.png`
|
|
87
|
+
)
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "public/favicon.ico",
|
|
91
|
+
content: fs.readFileSync(`${__dirname}/templates/public/favicon.ico`)
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "public/manifest.json",
|
|
95
|
+
content: fs.readFileSync(`${__dirname}/templates/public/manifest.json`)
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "public/service-worker.js",
|
|
99
|
+
content: fs.readFileSync(
|
|
100
|
+
`${__dirname}/templates/public/service-worker.js`
|
|
101
|
+
)
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "public/splash-screen-1024x1024.png",
|
|
105
|
+
content: fs.readFileSync(
|
|
106
|
+
`${__dirname}/templates/public/splash-screen-1024x1024.png`
|
|
107
|
+
)
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "ui/components/button/index.js",
|
|
111
|
+
content: fs.readFileSync(
|
|
112
|
+
`${__dirname}/templates/ui/components/button/index.js`,
|
|
113
|
+
"utf-8"
|
|
114
|
+
)
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "ui/layouts/app/index.js",
|
|
118
|
+
content: fs.readFileSync(
|
|
119
|
+
`${__dirname}/templates/ui/layouts/app/index.js`,
|
|
120
|
+
"utf-8"
|
|
121
|
+
)
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "ui/pages/error/index.js",
|
|
125
|
+
content: fs.readFileSync(
|
|
126
|
+
`${__dirname}/templates/ui/pages/error/index.js`,
|
|
127
|
+
"utf-8"
|
|
128
|
+
)
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "ui/pages/index/index.js",
|
|
132
|
+
content: fs.readFileSync(
|
|
133
|
+
`${__dirname}/templates/ui/pages/index/index.js`,
|
|
134
|
+
"utf-8"
|
|
135
|
+
)
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "index.client.js",
|
|
139
|
+
content: fs.readFileSync(
|
|
140
|
+
`${__dirname}/templates/index.client.js`,
|
|
141
|
+
"utf-8"
|
|
142
|
+
)
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: "index.css",
|
|
146
|
+
content: fs.readFileSync(`${__dirname}/templates/index.css`, "utf-8")
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "index.html",
|
|
150
|
+
content: fs.readFileSync(`${__dirname}/templates/index.html`, "utf-8")
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "index.server.js",
|
|
154
|
+
content: fs.readFileSync(
|
|
155
|
+
`${__dirname}/templates/index.server.js`,
|
|
156
|
+
"utf-8"
|
|
157
|
+
)
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
name: "settings.development.json",
|
|
161
|
+
content: fs.readFileSync(
|
|
162
|
+
`${__dirname}/templates/settings.development.json`,
|
|
163
|
+
"utf-8"
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
]);
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
process.loader.text("Installing dependencies...");
|
|
169
|
+
}, 1500);
|
|
170
|
+
exec(
|
|
171
|
+
`cd ./${projectName} && npm install --save @joystick.js/ui @joystick.js/node ${npmRegistry}`,
|
|
172
|
+
(stderr, stdout) => {
|
|
173
|
+
if (stderr) {
|
|
174
|
+
process.loader.stop();
|
|
175
|
+
console.warn(stderr);
|
|
176
|
+
} else {
|
|
177
|
+
process.loader.stop();
|
|
178
|
+
console.log(
|
|
179
|
+
`${chalk.green(
|
|
180
|
+
"Project created! To get started, run:"
|
|
181
|
+
)}
|
|
182
|
+
cd ${projectName} && joystick start`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
} catch (exception) {
|
|
188
|
+
console.warn(exception);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
export {
|
|
192
|
+
create_default as default
|
|
193
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--brand: #ffcc00;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
*,
|
|
6
|
+
*:before,
|
|
7
|
+
*:after {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
|
|
13
|
+
font-size: 16px;
|
|
14
|
+
background: #fff;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
ul,
|
|
18
|
+
ol {
|
|
19
|
+
list-style: none;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html class="no-js" lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Joystick</title>
|
|
6
|
+
<meta name="description" content="An awesome JavaScript app that's under development.">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<meta name="theme-color" content="#FFCC00">
|
|
9
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon-152x152.png">
|
|
10
|
+
<link rel="stylesheet" href="/_joystick/index.css">
|
|
11
|
+
<link rel="manifest" href="/manifest.json">
|
|
12
|
+
${css}
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="app"></div>
|
|
16
|
+
${scripts}
|
|
17
|
+
<script>
|
|
18
|
+
if ("serviceWorker" in navigator) {
|
|
19
|
+
navigator.serviceWorker.register("/service-worker.js");
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import node from "@joystick.js/node";
|
|
2
|
+
import api from "./api";
|
|
3
|
+
|
|
4
|
+
node.app({
|
|
5
|
+
api,
|
|
6
|
+
routes: {
|
|
7
|
+
"/": (req, res) => {
|
|
8
|
+
res.render("ui/pages/index/index.js", {
|
|
9
|
+
layout: "ui/layouts/app/index.js",
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
"*": (req, res) => {
|
|
13
|
+
res.render("ui/pages/error/index.js", {
|
|
14
|
+
layout: "ui/layouts/app/index.js",
|
|
15
|
+
props: {
|
|
16
|
+
statusCode: 404,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
});
|
|
Binary file
|