-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Feature/ticket 1159 nxext stencil vue integration #1160
Open
NickersWeb
wants to merge
14
commits into
nxext:main
Choose a base branch
from
NickersWeb:feature/ticket-1159-nxext-stencil-vue-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
178f090
#1159 package.json including @nx/vue for stencil vue integration
327e3e1
#1159 versions.ts STENCIL_OUTPUTTARGET_VERSION including vue
5e2ce0f
#1159 fetch-latest-versions.ts including @stencil/vue-output-target
e261df0
#1159 add-outputtarget/add-vue generator.ts for vue
d8ebde8
#1159 schema.d.ts and schema.json OutputTargetType including vue
b261e41
#1159 .github ISSUE_TEMPLATE - including Vue
7370578
#1159 add-outputtarget.ts outputtargetGenerator extend with addVueGen…
b286f77
#1159 generators.md mention vue in @nxext/stencil:add-outputtarget se…
4d2a0c3
#1159 e2e stencil e2e library.test.ts - include test 'should generate…
dfdba42
#1159 README.md mention vue as part of stencil integration
b236041
#1159 pnpm format code
92a9bd0
#1159 generators.md outputType format
966d846
#1159 generators.md and json for stencil outputtarget
2f64ac7
#1159 generators.md stencil output target; including vue
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/stencil/src/generators/add-outputtarget/add-outputtarget-vue.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { createTestUILib } from '../../utils/testing'; | ||
import { uniq } from '@nx/plugin/testing'; | ||
import { Tree } from '@nx/devkit'; | ||
import { outputtargetGenerator } from './add-outputtarget'; | ||
import { AddOutputtargetSchematicSchema } from './schema'; | ||
|
||
xdescribe('add-outputtarget vue', () => { | ||
let tree: Tree; | ||
const projectName = uniq('testprojekt'); | ||
const projectAppDirectory = `apps/${projectName}`; | ||
const projectLibDirectory = `libs/${projectName}`; | ||
const options = { | ||
projectName: projectName, | ||
publishable: false, | ||
skipFormat: false, | ||
}; | ||
|
||
beforeEach(async () => { | ||
tree = await createTestUILib(projectLibDirectory); | ||
}); | ||
|
||
describe('using vue', () => { | ||
const vueOptions: AddOutputtargetSchematicSchema = { | ||
...options, | ||
unitTestRunner: 'none', | ||
outputType: 'vue', | ||
}; | ||
|
||
it('should not generate default vue library', async () => { | ||
await outputtargetGenerator(tree, vueOptions); | ||
|
||
expect( | ||
tree.exists(`libs/${projectName}-vue/src/lib/${projectName}-vue.tsx`) | ||
).toBeFalsy(); | ||
expect( | ||
tree.exists( | ||
`libs/${projectName}-vue/src/lib/${projectName}-vue.spec.tsx` | ||
) | ||
).toBeFalsy(); | ||
expect( | ||
tree.exists(`libs/${projectName}-vue/src/lib/${projectName}-vue.css`) | ||
).toBeFalsy(); | ||
|
||
const indexFile: Buffer = tree.read( | ||
`libs/${projectName}-vue/src/index.ts` | ||
); | ||
expect(indexFile.toString()).toMatch( | ||
`export * from './generated/components';` | ||
); | ||
}); | ||
|
||
it('should add vueOutputTarget', async () => { | ||
await outputtargetGenerator(tree, vueOptions); | ||
|
||
expect( | ||
tree | ||
.read(`libs/${projectName}/stencil.config.ts`) | ||
.includes( | ||
`import { vueOutputTarget } from '@stencil/vue-output-target';` | ||
) | ||
).toBeTruthy(); | ||
|
||
expect( | ||
tree | ||
.read(`libs/${projectName}/stencil.config.ts`) | ||
.includes(`vueOutputTarget({`) | ||
).toBeTruthy(); | ||
}); | ||
|
||
it('should be able to generate a publishable lib', async () => { | ||
await outputtargetGenerator(tree, { | ||
...vueOptions, | ||
publishable: true, | ||
importPath: '@proj/mylib', | ||
}); | ||
|
||
expect(tree.exists(`libs/${projectName}/package.json`)).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
packages/stencil/src/generators/add-outputtarget/add-vue/generator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { | ||
addDependenciesToPackageJson, | ||
applyChangesToString, | ||
ensurePackage, | ||
getWorkspaceLayout, | ||
NX_VERSION, | ||
readProjectConfiguration, | ||
runTasksInSerial, | ||
Tree, | ||
} from '@nx/devkit'; | ||
import { initGenerator as jsInitGenerator } from '@nx/js'; | ||
import { AddOutputtargetSchematicSchema } from '../schema'; | ||
import { Linter } from '@nx/eslint'; | ||
import { STENCIL_OUTPUTTARGET_VERSION } from '../../../utils/versions'; | ||
import * as ts from 'typescript'; | ||
import { getDistDir, getRelativePath } from '../../../utils/fileutils'; | ||
import { addImport } from '@nxext/common'; | ||
import { addOutputTarget } from '../../../stencil-core-utils'; | ||
import { calculateStencilSourceOptions } from '../lib/calculate-stencil-source-options'; | ||
|
||
async function prepareVueLibrary( | ||
host: Tree, | ||
options: AddOutputtargetSchematicSchema | ||
) { | ||
const { libsDir } = getWorkspaceLayout(host); | ||
const vueProjectName = `${options.projectName}-vue`; | ||
const vueProjectDir = `libs/${vueProjectName}`; | ||
|
||
const jsInitTask = await jsInitGenerator(host, { | ||
...options, | ||
tsConfigName: 'tsconfig.base.json', | ||
skipFormat: true, | ||
}); | ||
|
||
ensurePackage('@nx/vue', NX_VERSION); | ||
const { libraryGenerator } = await import('@nx/vue'); | ||
const libraryTarget = await libraryGenerator(host, { | ||
directory: vueProjectDir, | ||
publishable: options.publishable, | ||
bundler: options.publishable ? 'vite' : 'none', | ||
importPath: options.importPath, | ||
component: false, | ||
skipTsConfig: false, | ||
skipFormat: true, | ||
unitTestRunner: 'vitest', | ||
linter: Linter.EsLint, | ||
}); | ||
|
||
await addDependenciesToPackageJson( | ||
host, | ||
{}, | ||
{ | ||
'@stencil/vue-output-target': STENCIL_OUTPUTTARGET_VERSION['vue'], | ||
} | ||
); | ||
|
||
host.write( | ||
`${libsDir}/${vueProjectName}/src/index.ts`, | ||
`export * from './generated/components';` | ||
); | ||
|
||
return runTasksInSerial(jsInitTask, libraryTarget); | ||
} | ||
|
||
function addVueOutputtarget( | ||
tree: Tree, | ||
projectName: string, | ||
stencilProjectConfig, | ||
stencilConfigPath: string, | ||
stencilConfigSource: ts.SourceFile, | ||
packageName: string | ||
) { | ||
const vueProjectConfig = readProjectConfiguration(tree, `${projectName}-vue`); | ||
const realtivePath = getRelativePath( | ||
getDistDir(stencilProjectConfig.root), | ||
vueProjectConfig.root | ||
); | ||
|
||
const changes = applyChangesToString(stencilConfigSource.text, [ | ||
...addImport( | ||
stencilConfigSource, | ||
`import { vueOutputTarget } from '@stencil/vue-output-target';` | ||
), | ||
...addOutputTarget( | ||
stencilConfigSource, | ||
` | ||
vueOutputTarget({ | ||
componentCorePackage: '${packageName}', | ||
proxiesFile: '${realtivePath}/src/generated/components.ts', | ||
includeDefineCustomElements: true, | ||
}) | ||
` | ||
), | ||
]); | ||
tree.write(stencilConfigPath, changes); | ||
} | ||
|
||
export async function addVueGenerator( | ||
host: Tree, | ||
options: AddOutputtargetSchematicSchema | ||
) { | ||
const libraryTarget = await prepareVueLibrary(host, options); | ||
|
||
const { | ||
stencilProjectConfig, | ||
stencilConfigPath, | ||
stencilConfigSource, | ||
packageName, | ||
} = calculateStencilSourceOptions(host, options.projectName); | ||
|
||
addVueOutputtarget( | ||
host, | ||
options.projectName, | ||
stencilProjectConfig, | ||
stencilConfigPath, | ||
stencilConfigSource, | ||
packageName | ||
); | ||
|
||
return libraryTarget; | ||
} | ||
|
||
export default addVueGenerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be skipped.