Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for Quasar Framework #865

Merged
merged 2 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions server/src/modes/template/tagProviders/externalTagProviders.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import * as ts from 'typescript';
import * as fs from 'fs';
import { join } from 'path';

import { IHTMLTagProvider, Priority } from './common';

import * as elementTags from 'element-helper-json/element-tags.json';
Expand All @@ -21,6 +25,20 @@ export const bootstrapTagProvider = getExternalTagProvider('bootstrap', bootstra
export const buefyTagProvider = getExternalTagProvider('buefy', buefyTags, buefyAttributes);
export const vuetifyTagProvider = getExternalTagProvider('vuetify', vuetifyTags, vuetifyAttributes);
Copy link
Member

@octref octref Aug 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM, see the other comment.


export function getQuasarTagProvider(workspacePath: string, pkg: any): IHTMLTagProvider | null {
const base = 'node_modules/quasar-framework';
const tagsPath = ts.findConfigFile(workspacePath, ts.sys.fileExists, join(base, pkg.vetur.tags));
const attrsPath = ts.findConfigFile(workspacePath, ts.sys.fileExists, join(base, pkg.vetur.attributes));

return tagsPath && attrsPath
? getExternalTagProvider(
'quasar',
JSON.parse(fs.readFileSync(tagsPath, 'utf-8')),
JSON.parse(fs.readFileSync(attrsPath, 'utf-8'))
)
: null;
}

export function getExternalTagProvider(id: string, tags: any, attributes: any): IHTMLTagProvider {
function findAttributeDetail(tag: string, attr: string) {
return attributes[attr] || attributes[tag + '/' + attr];
Expand Down
23 changes: 21 additions & 2 deletions server/src/modes/template/tagProviders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
onsenTagProvider,
bootstrapTagProvider,
buefyTagProvider,
vuetifyTagProvider
vuetifyTagProvider,
getQuasarTagProvider
} from './externalTagProviders';
export { getComponentTags } from './componentTags';
export { IHTMLTagProvider } from './common';

import * as ts from 'typescript';
import * as fs from 'fs';
import { join } from 'path';

export let allTagProviders: IHTMLTagProvider[] = [
getHTML5TagProvider(),
Expand All @@ -39,7 +41,8 @@ export function getTagProviderSettings(workspacePath: string | null | undefined)
onsen: false,
bootstrap: false,
buefy: false,
vuetify: false
vuetify: false,
quasar: false
};
if (!workspacePath) {
return settings;
Expand Down Expand Up @@ -68,6 +71,22 @@ export function getTagProviderSettings(workspacePath: string | null | undefined)
if (packageJson.dependencies['vuetify']) {
settings['vuetify'] = true;
}

const quasarPath = ts.findConfigFile(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the pattern above

  • Check if dependencies have quasar-framework
  • If so, call into the function getQuasarTagProvider, which should encapsulate the code for finding package.json, etc
  • If that returns null, do nothing
  • If that returns the tagProvider, set settings to true and push it to allTagProviders.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is best for all the ways Quasar can be consumed (through Quasar CLI, vue-cli-plugin-quasar, etc etc). Explained on private.

workspacePath,
ts.sys.fileExists,
join('node_modules', 'quasar-framework', 'package.json')
);
if (quasarPath) {
const quasarPkg = JSON.parse(fs.readFileSync(quasarPath, 'utf-8'));
if (quasarPkg.vetur) {
const provider = getQuasarTagProvider(workspacePath, quasarPkg);
if (provider !== null) {
allTagProviders.push(provider);
settings['quasar'] = true;
}
}
}
} catch (e) {}
return settings;
}
Expand Down