@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,12 @@
|
|
|
1
|
+
const EXPORT_DEFAULT_REGEX = new RegExp(/export default [a-zA-Z0-9]+/g);
|
|
2
|
+
const JOYSTICK_COMMENT_REGEX = new RegExp(/\<\!\-\-(.|\n|\r)*?-->/g);
|
|
3
|
+
const JOYSTICK_COMPONENT_REGEX = new RegExp(/\.component\(\{/g);
|
|
4
|
+
const JOYSTICK_UI_REGEX = new RegExp(/@joystick.js\/ui/g);
|
|
5
|
+
const OBJECT_REGEX = new RegExp(/{([^;]*)}/g);
|
|
6
|
+
export {
|
|
7
|
+
EXPORT_DEFAULT_REGEX,
|
|
8
|
+
JOYSTICK_COMMENT_REGEX,
|
|
9
|
+
JOYSTICK_COMPONENT_REGEX,
|
|
10
|
+
JOYSTICK_UI_REGEX,
|
|
11
|
+
OBJECT_REGEX
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
const isWindows = os.platform() === "win32";
|
|
3
|
+
var replaceBackslashesWithForwardSlashes_default = (path = "") => {
|
|
4
|
+
return isWindows ? path.replace(/\\/g, "/") : path;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
replaceBackslashesWithForwardSlashes_default as default
|
|
8
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import CLILog from "./CLILog.js";
|
|
2
|
+
import isObject from "./isObject.js";
|
|
3
|
+
var validateDatabasesFromSettings_default = (databases = []) => {
|
|
4
|
+
const databasesNotAsObjects = databases.filter(
|
|
5
|
+
(database) => !isObject(database)
|
|
6
|
+
);
|
|
7
|
+
const userDatabases = databases.filter((database) => !!database.users);
|
|
8
|
+
const queueDatabases = databases.filter((database) => !!database.queues);
|
|
9
|
+
if (databasesNotAsObjects && databasesNotAsObjects.length > 0) {
|
|
10
|
+
CLILog(`Please ensure that each database in the config.databases array in your settings.${process.env.NODE_ENV}.json is an object. Correct the array and restart your app.`, {
|
|
11
|
+
level: "danger",
|
|
12
|
+
docs: "https://github.com/cheatcode/joystick#databases"
|
|
13
|
+
});
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
if (userDatabases && userDatabases.length > 1) {
|
|
17
|
+
CLILog(`Please select a single database for your user accounts and restart your app.`, {
|
|
18
|
+
level: "danger",
|
|
19
|
+
docs: "https://github.com/cheatcode/joystick#users-database"
|
|
20
|
+
});
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
if (queueDatabases && queueDatabases.length > 1) {
|
|
24
|
+
CLILog(`Please select a single database for your queues and restart your app.`, {
|
|
25
|
+
level: "danger",
|
|
26
|
+
docs: "https://github.com/cheatcode/joystick#queues-database"
|
|
27
|
+
});
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
validateDatabasesFromSettings_default as default
|
|
34
|
+
};
|
package/dist/lib/wait.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@joystick.js/cli-canary",
|
|
3
|
+
"version": "0.0.0-canary.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI for the Joystick JavaScript framework.",
|
|
6
|
+
"main": "development.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"joystick": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "node .build/index.js",
|
|
12
|
+
"canary:release": "export NODE_ENV=development && npm run build && node canary.js",
|
|
13
|
+
"production:release": "export NODE_ENV=production && npm run build && node release.js",
|
|
14
|
+
"win:development:release": "SET NODE_ENV=development&& npm run build && node release.js",
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"cross-env": "^7.0.3",
|
|
22
|
+
"semver": "^7.3.5"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@babel/code-frame": "^7.15.8",
|
|
26
|
+
"acorn": "^8.5.0",
|
|
27
|
+
"ascii-table": "^0.0.9",
|
|
28
|
+
"chalk": "^4.1.2",
|
|
29
|
+
"chokidar": "^3.5.2",
|
|
30
|
+
"command-exists": "^1.2.9",
|
|
31
|
+
"cross-port-killer": "^1.4.0",
|
|
32
|
+
"currency-formatter": "^1.5.9",
|
|
33
|
+
"esbuild": "^0.17.19",
|
|
34
|
+
"esbuild-plugin-svg": "^0.1.0",
|
|
35
|
+
"form-data": "^4.0.0",
|
|
36
|
+
"fs-extra": "^10.0.0",
|
|
37
|
+
"inquirer": "^8.2.0",
|
|
38
|
+
"kill-port-process": "^3.1.0",
|
|
39
|
+
"lodash": "^4.17.21",
|
|
40
|
+
"mongo-uri-tool": "^1.0.1",
|
|
41
|
+
"mongodb": "^4.1.3",
|
|
42
|
+
"netstats": "^0.0.6",
|
|
43
|
+
"node-fetch": "^3.2.0",
|
|
44
|
+
"node-watch": "^0.7.2",
|
|
45
|
+
"pg": "^8.7.3",
|
|
46
|
+
"port-pid": "^0.0.7",
|
|
47
|
+
"ps-node": "^0.1.6",
|
|
48
|
+
"replace-in-files": "^3.0.0",
|
|
49
|
+
"selective-whitespace": "^1.0.4",
|
|
50
|
+
"systeminformation": "^5.11.0",
|
|
51
|
+
"ws": "^8.2.3",
|
|
52
|
+
"xmlhttprequest": "^1.8.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/release.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const packageJSON = require("./package.json");
|
|
8
|
+
const canaryJSON = require('./canary.json');
|
|
9
|
+
|
|
10
|
+
const updatePackageJSONVersion = (packageJSON, originalVersion) => {
|
|
11
|
+
packageJSON.version = originalVersion;
|
|
12
|
+
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const updatePackageJSONDependencies = (packageJSON, canaryJSON) => {
|
|
16
|
+
packageJSON.dependencies = canaryJSON?.dependencies;
|
|
17
|
+
packageJSON.devDependencies = canaryJSON?.devDependencies;
|
|
18
|
+
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
updatePackageJSONDependencies(packageJSON, canaryJSON);
|
|
22
|
+
|
|
23
|
+
const originalVersion = `${packageJSON.version}`;
|
|
24
|
+
|
|
25
|
+
const version = semver.inc(packageJSON.version,
|
|
26
|
+
"prerelease",
|
|
27
|
+
"beta"
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
execSync(
|
|
32
|
+
`npm version ${version} --allow-same-version && npm publish --access public`
|
|
33
|
+
);
|
|
34
|
+
} catch (exception) {
|
|
35
|
+
updatePackageJSONVersion(originalVersion, version);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (process.env.NODE_ENV === 'production') {
|
|
39
|
+
execSync(`git add . && git commit -m "release @joystick.js/cli@${version}"`);
|
|
40
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
|
|
7
|
+
const functionNames = Object.keys(functions);
|
|
8
|
+
const functionsCalled = process.argv.filter((arg) => functionNames.includes(arg));
|
|
9
|
+
|
|
10
|
+
const showHelp = process.argv.some((arg) => ['-h', '--help'].includes(arg));
|
|
11
|
+
|
|
12
|
+
if (showHelp || functionsCalled.length === 0) {
|
|
13
|
+
help();
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (functionsCalled.length > 1) {
|
|
18
|
+
console.log(chalk.red('Only one function can be called at a time.'));
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (functionsCalled.includes('build')) {
|
|
23
|
+
const args = getArgs(functions.build.args);
|
|
24
|
+
const options = getOptions(functions.build.options);
|
|
25
|
+
|
|
26
|
+
if (functions.build.function && typeof functions.build.function === 'function') {
|
|
27
|
+
functions.build.function(args, options);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (functionsCalled.includes('create')) {
|
|
32
|
+
const args = getArgs(functions.create.args);
|
|
33
|
+
const options = getOptions(functions.create.options);
|
|
34
|
+
|
|
35
|
+
if (!args.name) {
|
|
36
|
+
console.log(chalk.red('Must pass a <name> for your app to joystick create. Run joystick --help for examples.'));
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (functions.create.function && typeof functions.create.function === 'function') {
|
|
41
|
+
functions.create.function(args, options);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (functionsCalled.includes('logout')) {
|
|
46
|
+
const args = getArgs(functions.logout.args);
|
|
47
|
+
const options = getOptions(functions.logout.options);
|
|
48
|
+
|
|
49
|
+
if (functions.logout.function && typeof functions.logout.function === 'function') {
|
|
50
|
+
functions.logout.function(args, options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (functionsCalled.includes('push')) {
|
|
55
|
+
const args = getArgs(functions.push.args);
|
|
56
|
+
const options = getOptions(functions.push.options);
|
|
57
|
+
|
|
58
|
+
if (functions.push.function && typeof functions.push.function === 'function') {
|
|
59
|
+
functions.push.function(args, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (functionsCalled.includes('start')) {
|
|
64
|
+
const args = getArgs(functions.start.args);
|
|
65
|
+
const options = getOptions(functions.start.options);
|
|
66
|
+
|
|
67
|
+
if (functions.start.function && typeof functions.start.function === 'function') {
|
|
68
|
+
functions.start.function(args, options);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (functionsCalled.includes('update')) {
|
|
73
|
+
const args = getArgs(functions.update.args);
|
|
74
|
+
const options = getOptions(functions.update.options);
|
|
75
|
+
|
|
76
|
+
if (functions.update.function && typeof functions.update.function === 'function') {
|
|
77
|
+
functions.update.function(args, options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (functionsCalled.includes('use')) {
|
|
82
|
+
const args = getArgs(functions.use.args);
|
|
83
|
+
const options = getOptions(functions.use.options);
|
|
84
|
+
|
|
85
|
+
if (functions.use.function && typeof functions.use.function === 'function') {
|
|
86
|
+
functions.use.function(args, options);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import masterIgnoreList from "../../lib/masterIgnoreList.js";
|
|
3
|
+
|
|
4
|
+
export default (excludedPaths = []) => {
|
|
5
|
+
const gitignore = fs.existsSync(".gitignore")
|
|
6
|
+
? fs.readFileSync(".gitignore", "utf-8")
|
|
7
|
+
: "";
|
|
8
|
+
const gitignoreFiles = gitignore?.split("\n")?.filter((file) => {
|
|
9
|
+
return !file?.includes("#") && file?.trim() !== "";
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const ignoreFiles = [
|
|
13
|
+
...gitignoreFiles,
|
|
14
|
+
...excludedPaths,
|
|
15
|
+
...(masterIgnoreList || [])?.map((ignore) => {
|
|
16
|
+
return `${process.cwd()}/./${ignore}`;
|
|
17
|
+
}),
|
|
18
|
+
"*.tar",
|
|
19
|
+
"*.tar.gz",
|
|
20
|
+
"*.tar.xz",
|
|
21
|
+
]?.filter((item, itemIndex, array) => {
|
|
22
|
+
return array.indexOf(item) === itemIndex;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const excludeList = `{${ignoreFiles
|
|
26
|
+
?.map((ignoreFile) => `"${ignoreFile}"`)
|
|
27
|
+
.join(",")}}`;
|
|
28
|
+
|
|
29
|
+
return excludeList;
|
|
30
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
|
|
10
|
+
export default async (args = {}, options = {}) => {
|
|
11
|
+
if (!options?.type) {
|
|
12
|
+
CLILog("Must pass a type for your build.", {
|
|
13
|
+
level: "danger",
|
|
14
|
+
docs: "https://cheatcode.co/docs/joystick/cli#build",
|
|
15
|
+
});
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
console.log("");
|
|
20
|
+
const loader = new Loader({
|
|
21
|
+
padding: options?.isDeploy ? " " : "",
|
|
22
|
+
defaultMessage: "Building app...",
|
|
23
|
+
});
|
|
24
|
+
loader.text("Building app...");
|
|
25
|
+
|
|
26
|
+
const environment = options?.environment || "production";
|
|
27
|
+
const settings = !options?.continuousIntegration
|
|
28
|
+
? await loadSettings(environment)
|
|
29
|
+
: null;
|
|
30
|
+
const filesToBuild = getFilesToBuild(settings?.config?.build?.excludedPaths);
|
|
31
|
+
const outputPath = ".build";
|
|
32
|
+
const outputPathForBuildType =
|
|
33
|
+
options?.type === "tar" ? `${outputPath}/.tar` : outputPath;
|
|
34
|
+
|
|
35
|
+
await buildFiles(
|
|
36
|
+
filesToBuild,
|
|
37
|
+
outputPathForBuildType,
|
|
38
|
+
// NOTE: Treat standalone builds as being for production by default.
|
|
39
|
+
environment
|
|
40
|
+
).catch((error) => {
|
|
41
|
+
console.warn(error);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (options?.type === "tar") {
|
|
45
|
+
const ignoreList = getTarIgnoreList(settings?.config?.build?.excludedPaths);
|
|
46
|
+
|
|
47
|
+
console.log(ignoreList);
|
|
48
|
+
|
|
49
|
+
child_process.execSync(
|
|
50
|
+
`cd ${outputPath}/.tar && tar -cf ../build.tar.xz --exclude=${ignoreList} .`
|
|
51
|
+
);
|
|
52
|
+
child_process.execSync(`cd ${outputPath} && rm -rf .tar`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
loader.stable("");
|
|
56
|
+
loader.stop();
|
|
57
|
+
|
|
58
|
+
console.log(
|
|
59
|
+
chalk.greenBright(`App built as ${options?.type} to ${outputPath}!\n`)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return Promise.resolve();
|
|
63
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export 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
|
+
|
|
17
|
+
return JSON.stringify(packageJSON, null, 2);
|
|
18
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
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
|
+
|
|
9
|
+
const npmRegistry =
|
|
10
|
+
process.env.NODE_ENV === "development"
|
|
11
|
+
? "--registry http://localhost:4873"
|
|
12
|
+
: "";
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
|
|
16
|
+
const createFiles = (projectName, files = []) => {
|
|
17
|
+
files.forEach(({ name, content }) => {
|
|
18
|
+
fs.writeFileSync(`./${projectName}/${name}`, content);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const createFolders = (projectName, folders = []) => {
|
|
23
|
+
folders.forEach((folder) => {
|
|
24
|
+
fs.mkdirSync(`./${projectName}/${folder}`);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const createPackageJSON = (projectName = "") => {
|
|
29
|
+
fs.writeFileSync(
|
|
30
|
+
`./${projectName}/package.json`,
|
|
31
|
+
buildPackageJSON(projectName)
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const createJoystickFolder = (projectName = "") => {
|
|
36
|
+
fs.mkdirSync(`./${projectName}/.joystick`);
|
|
37
|
+
fs.mkdirSync(`./${projectName}/.joystick/build`);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const createProjectFolder = (projectName = "") => {
|
|
41
|
+
return fs.mkdirSync(`./${projectName}`);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const checkIfProjectExists = (projectName = "") => {
|
|
45
|
+
return fs.existsSync(`./${projectName}`);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default (args = {}) => {
|
|
49
|
+
try {
|
|
50
|
+
process.loader = new Loader({ defaultMessage: "Starting app..." });
|
|
51
|
+
process.loader.text("Creating app...");
|
|
52
|
+
|
|
53
|
+
const projectName = args?.name;
|
|
54
|
+
const projectAlreadyExists = checkIfProjectExists(projectName);
|
|
55
|
+
|
|
56
|
+
if (projectAlreadyExists) {
|
|
57
|
+
console.log(
|
|
58
|
+
chalk.red(
|
|
59
|
+
`A folder with the name ${projectName} already exists. Please choose a different name and try again.`
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
createProjectFolder(projectName);
|
|
66
|
+
createJoystickFolder(projectName);
|
|
67
|
+
createPackageJSON(projectName);
|
|
68
|
+
|
|
69
|
+
createFolders(projectName, [
|
|
70
|
+
"api",
|
|
71
|
+
"i18n",
|
|
72
|
+
"ui",
|
|
73
|
+
"ui/components",
|
|
74
|
+
"ui/components/button",
|
|
75
|
+
"ui/layouts",
|
|
76
|
+
"ui/layouts/app",
|
|
77
|
+
"ui/pages",
|
|
78
|
+
"ui/pages/error",
|
|
79
|
+
"ui/pages/index",
|
|
80
|
+
"lib",
|
|
81
|
+
"public",
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
createFiles(projectName, [
|
|
85
|
+
{
|
|
86
|
+
name: "api/index.js",
|
|
87
|
+
content: fs.readFileSync(
|
|
88
|
+
`${__dirname}/templates/api/index.js`,
|
|
89
|
+
"utf-8"
|
|
90
|
+
),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "i18n/en-US.js",
|
|
94
|
+
content: fs.readFileSync(
|
|
95
|
+
`${__dirname}/templates/i18n/en-US.js`,
|
|
96
|
+
"utf-8"
|
|
97
|
+
),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "public/apple-touch-icon-152x152.png",
|
|
101
|
+
content: fs.readFileSync(
|
|
102
|
+
`${__dirname}/templates/public/apple-touch-icon-152x152.png`
|
|
103
|
+
),
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "public/favicon.ico",
|
|
107
|
+
content: fs.readFileSync(`${__dirname}/templates/public/favicon.ico`),
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "public/manifest.json",
|
|
111
|
+
content: fs.readFileSync(`${__dirname}/templates/public/manifest.json`),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "public/service-worker.js",
|
|
115
|
+
content: fs.readFileSync(
|
|
116
|
+
`${__dirname}/templates/public/service-worker.js`
|
|
117
|
+
),
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "public/splash-screen-1024x1024.png",
|
|
121
|
+
content: fs.readFileSync(
|
|
122
|
+
`${__dirname}/templates/public/splash-screen-1024x1024.png`
|
|
123
|
+
),
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "ui/components/button/index.js",
|
|
127
|
+
content: fs.readFileSync(
|
|
128
|
+
`${__dirname}/templates/ui/components/button/index.js`,
|
|
129
|
+
"utf-8"
|
|
130
|
+
),
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "ui/layouts/app/index.js",
|
|
134
|
+
content: fs.readFileSync(
|
|
135
|
+
`${__dirname}/templates/ui/layouts/app/index.js`,
|
|
136
|
+
"utf-8"
|
|
137
|
+
),
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "ui/pages/error/index.js",
|
|
141
|
+
content: fs.readFileSync(
|
|
142
|
+
`${__dirname}/templates/ui/pages/error/index.js`,
|
|
143
|
+
"utf-8"
|
|
144
|
+
),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "ui/pages/index/index.js",
|
|
148
|
+
content: fs.readFileSync(
|
|
149
|
+
`${__dirname}/templates/ui/pages/index/index.js`,
|
|
150
|
+
"utf-8"
|
|
151
|
+
),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "index.client.js",
|
|
155
|
+
content: fs.readFileSync(
|
|
156
|
+
`${__dirname}/templates/index.client.js`,
|
|
157
|
+
"utf-8"
|
|
158
|
+
),
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "index.css",
|
|
162
|
+
content: fs.readFileSync(`${__dirname}/templates/index.css`, "utf-8"),
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "index.html",
|
|
166
|
+
content: fs.readFileSync(`${__dirname}/templates/index.html`, "utf-8"),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "index.server.js",
|
|
170
|
+
content: fs.readFileSync(
|
|
171
|
+
`${__dirname}/templates/index.server.js`,
|
|
172
|
+
"utf-8"
|
|
173
|
+
),
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "settings.development.json",
|
|
177
|
+
content: fs.readFileSync(
|
|
178
|
+
`${__dirname}/templates/settings.development.json`,
|
|
179
|
+
"utf-8"
|
|
180
|
+
),
|
|
181
|
+
},
|
|
182
|
+
]);
|
|
183
|
+
|
|
184
|
+
// NOTE: Pure aesthetics. Above step completes so quickly that it almost looks like
|
|
185
|
+
// it's skipped. Add a buffer of 1.5s here to make for a better dev experience.
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
process.loader.text("Installing dependencies...");
|
|
188
|
+
}, 1500);
|
|
189
|
+
|
|
190
|
+
exec(
|
|
191
|
+
`cd ./${projectName} && npm install --save @joystick.js/ui @joystick.js/node ${npmRegistry}`,
|
|
192
|
+
(stderr, stdout) => {
|
|
193
|
+
if (stderr) {
|
|
194
|
+
process.loader.stop();
|
|
195
|
+
console.warn(stderr);
|
|
196
|
+
} else {
|
|
197
|
+
process.loader.stop();
|
|
198
|
+
console.log(
|
|
199
|
+
`${chalk.green(
|
|
200
|
+
"Project created! To get started, run:"
|
|
201
|
+
)}\ncd ${projectName} && joystick start`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
} catch (exception) {
|
|
207
|
+
console.warn(exception);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
@@ -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>
|