Skip to content

Commit 009eef3

Browse files
committed
Changed whitespace to respect with original authors preferences, removed some unneeded items.
1 parent a4b6bd1 commit 009eef3

4 files changed

Lines changed: 262 additions & 264 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ For now this is only a wrapper around `git clone`. After you pull down a repo yo
100100

101101
* Instead of exposing your password for the `quickbase-cli.config.js` file you can rely on an environment variable called `QUICKBASE_CLI_PASSWORD`. If you have that variable defined and leave the `password` empty when prompted the `qb deploy` command will use it instead. Always practice safe passwords.
102102

103-
* The same can also be done with username (using `QUICKBASE_CLI_USERNAME`), user token (using `QUICKBASE_CLI_USERTOKEN`, sort of an Admin token) and/or app token (using `QUICKBASE_CLI_APPTOKEN`).
103+
* The same can also be done with username (using `QUICKBASE_CLI_USERNAME`), user token (using `QUICKBASE_CLI_USERTOKEN`) and/or app token (using `QUICKBASE_CLI_APPTOKEN`).
104104

105105
* ~~Moves are being made to add cool shit like a build process, global defaults, awesome starter templates, and pulling down existing code files from QuickBase. They're not out yet, so for now you're on your own.~~
106106

bin/qb-deploy.js

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ const readFile = util.promisify(fs.readFile);
1616
const stat = util.promisify(fs.stat);
1717

1818
program
19-
.option('-w, --watch', 'deploy files on change')
20-
.option(
21-
'-x --replace',
22-
'replace css and js file paths inside html file with their QuickBase url'
23-
)
24-
.parse(process.argv);
19+
.option('-w, --watch', 'deploy files on change')
20+
.option(
21+
'-x --replace',
22+
'replace css and js file paths inside html file with their QuickBase url'
23+
)
24+
.parse(process.argv);
2525

2626
const sourceArg = program.args[0] || '.';
2727
const configPath = require('../lib/find-config')(sourceArg);
@@ -31,98 +31,98 @@ const api = new ApiClient(config);
3131
qbDeploy(sourceArg);
3232

3333
if (program.watch) {
34-
console.log(`Watching for file changes in ${sourceArg}`);
35-
36-
watch(sourceArg, {}).on('change', fileName => {
37-
console.log(`\nChange detected in ${fileName}`);
38-
program.replace
39-
? qbDeploy(sourceArg)
40-
: qbDeploy(fileName);
41-
});
34+
console.log(`Watching for file changes in ${sourceArg}`);
35+
36+
watch(sourceArg, {}).on('change', fileName => {
37+
console.log(`\nChange detected in ${fileName}`);
38+
program.replace
39+
? qbDeploy(sourceArg)
40+
: qbDeploy(fileName);
41+
});
4242
}
4343

4444

4545
async function qbDeploy(source) {
46-
console.log('Uploading files to QuickBase...');
47-
48-
const stats = await fs.statSync(source);
49-
const isFile = stats.isFile();
50-
51-
//We authenticate here, before we make a series of asynchronous api calls for each file
52-
api.authenticateIfNeeded().then((authType) => {
53-
54-
if (isFile) {
55-
return uploadToQuickbase(source)
56-
.then(res =>
57-
console.log(`Successfully uploaded to QuickBase:\n=> ${source}`)
58-
)
59-
.catch(err => console.error(err));
60-
}
61-
62-
if (!isFile) {
63-
getFiles(source).then(files => {
64-
const uploadPromises = program.replace
65-
? files.map(file => replaceUrlsAndUpload(file, files))
66-
: files.map(file => uploadToQuickbase(file));
67-
68-
return Promise.all(uploadPromises)
69-
.then(res =>
70-
console.log(
71-
`Successfully uploaded to QuickBase:\n=> ${files.join('\n=> ')}`
72-
)
73-
)
74-
.catch(err => console.error(err));
75-
});
76-
}
77-
78-
}).catch((errorDesc) => console.error(errorDesc));
46+
console.log('Uploading files to QuickBase...');
47+
48+
const stats = await fs.statSync(source);
49+
const isFile = stats.isFile();
50+
51+
//We authenticate here, before we make a series of asynchronous api calls for each file
52+
api.authenticateIfNeeded().then((authType) => {
53+
54+
if (isFile) {
55+
return uploadToQuickbase(source)
56+
.then(res =>
57+
console.log(`Successfully uploaded to QuickBase:\n=> ${source}`)
58+
)
59+
.catch(err => console.error(err));
60+
}
61+
62+
if (!isFile) {
63+
getFiles(source).then(files => {
64+
const uploadPromises = program.replace
65+
? files.map(file => replaceUrlsAndUpload(file, files))
66+
: files.map(file => uploadToQuickbase(file));
67+
68+
return Promise.all(uploadPromises)
69+
.then(res =>
70+
console.log(
71+
`Successfully uploaded to QuickBase:\n=> ${files.join('\n=> ')}`
72+
)
73+
)
74+
.catch(err => console.error(err));
75+
});
76+
}
77+
78+
}).catch((errorDesc) => console.error(errorDesc));
7979

8080
}
8181

8282

8383
function uploadToQuickbase(file, fileContents) {
84-
let fileName = path.basename(file);
85-
let codePageName;
84+
let fileName = path.basename(file);
85+
let codePageName;
8686

87-
if (!fileContents) {
88-
fileContents = fs.readFileSync(file, 'utf-8');
89-
}
87+
if (!fileContents) {
88+
fileContents = fs.readFileSync(file, 'utf-8');
89+
}
9090

91-
if (config.appName) {
92-
codePageName = `${config.appName}-${fileName}`;
93-
} else {
94-
codePageName = fileName;
95-
}
91+
if (config.appName) {
92+
codePageName = `${config.appName}-${fileName}`;
93+
} else {
94+
codePageName = fileName;
95+
}
9696

97-
return api.uploadPage(codePageName, fileContents);
97+
return api.uploadPage(codePageName, fileContents);
9898
}
9999

100100

101101
async function replaceUrlsAndUpload(file, allFiles) {
102-
let fileContents = await readFile(file, 'utf-8');
102+
let fileContents = await readFile(file, 'utf-8');
103103

104-
allFiles.forEach(assetFile => {
105-
if (file !== assetFile) {
106-
const fileName = path.basename(assetFile);
107-
const regex = new RegExp(`("|')[^"]*${fileName}("|')`, 'g');
104+
allFiles.forEach(assetFile => {
105+
if (file !== assetFile) {
106+
const fileName = path.basename(assetFile);
107+
const regex = new RegExp(`("|')[^"]*${fileName}("|')`, 'g');
108108

109-
fileContents = fileContents.replace(
110-
regex,
111-
generateCustomPageUrl(path.basename(assetFile))
112-
);
113-
}
114-
});
109+
fileContents = fileContents.replace(
110+
regex,
111+
generateCustomPageUrl(path.basename(assetFile))
112+
);
113+
}
114+
});
115115

116-
return uploadToQuickbase(file, fileContents);
116+
return uploadToQuickbase(file, fileContents);
117117
}
118118

119119

120120
function generateCustomPageUrl(fileName) {
121-
const suffix = config.appName
122-
? `${config.appName}-${fileName}`
123-
: `${fileName}`;
121+
const suffix = config.appName
122+
? `${config.appName}-${fileName}`
123+
: `${fileName}`;
124124

125-
return `"https://${config.realm}.quickbase.com/db/${
126-
config.dbid
127-
}?a=dbpage&pagename=${suffix}"`;
125+
return `"https://${config.realm}.quickbase.com/db/${
126+
config.dbid
127+
}?a=dbpage&pagename=${suffix}"`;
128128
}

demo/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
</head>
88
<body>
99
<h1>Hello, world</h1>
10-
<p>This is a page, that should be deployed using quickbase-cli to quickbase, with styling and scripts properly referenced..!</p>
11-
<p class="check_css">If this paragraph is bold, CSS files are properly referenced!</p>
12-
<p class="check_js">If this paragraph is bold, JS files are properly referenced!</p>
13-
<p><em>Florian M.</em></p>
14-
10+
<p>This is a page, that should be deployed using quickbase-cli to quickbase, with styling and scripts properly referenced.</p>
11+
<p class="check_css">If this paragraph is bold, CSS files are properly referenced.</p>
12+
<p class="check_js">If this paragraph is bold, JS files are properly referenced.</p>
1513
<script src="static/bundle.js"></script>
1614
</body>
1715
</html>

0 commit comments

Comments
 (0)