-
Notifications
You must be signed in to change notification settings - Fork 14
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] Add 'UI5 Workspace' Support #494
Conversation
615a153
to
1504c7a
Compare
198aa78
to
21f5b0c
Compare
a8d63dd
to
6f14964
Compare
6f14964
to
b811811
Compare
a566ebd
to
73f016f
Compare
73f016f
to
7847b89
Compare
7847b89
to
0ba89b7
Compare
6663b14
to
a8d996f
Compare
Pass it to NodePackageDependencies-Provider and ui5FrameworkHelper
…of module ID This should make the use of workspaces easier. Framework projects are matched based on the name in the ui5.yaml instead of the package.json name (= module ID). This allows for example framework projects to be contained in packages that are named differently from the local copy. E.g. "@openui5/sap.m-prebuilt" while the local copy does not have the "-prebuilt" suffix. Note however, that the NodePackageDependencies-provider still matches nodes using the module ID. The basic reason for this difference is that framework dependencies are typically declared using the project name, while npm dependencies are declared using the module ID. However, we could also enhance projectGraphBuilder in the future to additionally check whether a project can be resolved with a workspace once the project has been created and its name is known. This could catch those cases where the node provider could not find a workspace resolution for a given module ID.
This means resolution paths will always be resolved relative to the workspace config file location instead of the process CWD. Refactored some graph code to make creating workspaces reusable for other graph factory functions in the future. Extended related tests.
If no project is found, return null instead of undefined
While we don't expect this to happen in released UI5 versions, it might happen with development setups using UI5 Workspaces
feb2b82
to
8a5c1b8
Compare
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.
Awesome work @RandomByte. Well done!
lib/graph/Workspace.js
Outdated
|
||
/** | ||
* @param {object} options | ||
* @param {object} options.cwd Path to use for resolving all paths of the workspace configuration from. |
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.
cwd
is of type string, isn't?
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.
Correct!
}); | ||
|
||
test.afterEach.always((t) => { | ||
t.context.sinon.restore(); |
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.
missing esmock.purge(t.context.createWorkspace)
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.
I read https://github.com/iambumblehead/esmock/wiki#calling-esmock-await-import and came to think that this might not be necessary in this case.
esmock creates a new mock for every test in parallel. Cleaning up after each test to free memory (or for any other reason) seems unnecessary since ava executes this file in a separate process which it will kill after all tests are done.
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.
I remember we had to do it when await import
is used.... Interesting
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.
Yes, because await import
requires the delayed esmock.p
API which might interfere with other tests and therefore would require all tests to use .serial()
.
As it turns out, we don't use await import for "Workspace.js" anymore (this was used in an earlier version of this PR) and esmock
is enough 👍
Co-authored-by: Florian Vogt <florian.vogt@sap.com>
Keep modules that only contain extensions instead of discarding them. This allows to use workspaces for resolving extensions too. Before, only extensions in modules that also contained projects where resolved.
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.
Thank you very much @flovogt 😊
lib/graph/Workspace.js
Outdated
|
||
/** | ||
* @param {object} options | ||
* @param {object} options.cwd Path to use for resolving all paths of the workspace configuration from. |
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.
Correct!
lib/graph/helpers/ui5Framework.js
Outdated
`Try adding it temporarily to the root project's dependencies`); | ||
} | ||
|
||
// TODO: If a cyclic dependency is declared, this will empty the event loop. |
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.
This comment is obsolete. I solved this problem by taking in the _checkCycle
function from the ProjectGraph. I dreamed that I forgot to remove this comment but the next morning I thought it was just a dream. Oh well...
/*! | ||
* ${copyright} | ||
*/ | ||
console.log('HelloWorld'); |
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.
Done
test/fixtures/extension.a/ui5.yaml
Outdated
metadata: | ||
name: extension.a-ui5-yaml | ||
task: | ||
path: lib/extensionModule.js |
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.
Done
lib/graph/Workspace.js
Outdated
|
||
/** | ||
* For a given project name (e.g. the value of the <code>metadata.name</code> property in a ui5.yaml), | ||
* returns a Module instance or undefined depending on whether the project |
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.
* returns a Module instance or undefined depending on whether the project | |
* returns a module instance or <code>undefined</code> depending on whether the project |
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.
Done
lib/graph/Workspace.js
Outdated
* | ||
* @public | ||
* @param {string} projectName Name of the project | ||
* @returns {Promise<@ui5/project/graph/Module|undefined>} Module instance of undefined if none is found |
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.
* @returns {Promise<@ui5/project/graph/Module|undefined>} Module instance of undefined if none is found | |
* @returns {Promise<@ui5/project/graph/Module|undefined>} Module instance of <code>undefined</code> if none is found |
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.
Done
lib/graph/Workspace.js
Outdated
|
||
/** | ||
* For a given node id (e.g. the value of the name property in a package.json), | ||
* returns a Module instance or undefined depending on whether the module |
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.
* returns a Module instance or undefined depending on whether the module | |
* returns a module instance or <code>undefined</code> depending on whether the module |
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.
Done
lib/graph/Workspace.js
Outdated
* | ||
* @public | ||
* @param {string} nodeId Node ID of the module | ||
* @returns {Promise<@ui5/project/graph/Module|undefined>} Module instance of undefined if none is found |
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.
* @returns {Promise<@ui5/project/graph/Module|undefined>} Module instance of undefined if none is found | |
* @returns {Promise<@ui5/project/graph/Module|undefined>} Module instance of <code>undefined</code> if none is found |
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.
Done
}); | ||
|
||
test.afterEach.always((t) => { | ||
t.context.sinon.restore(); |
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.
I remember we had to do it when await import
is used.... Interesting
* @public | ||
* @typedef {object} @ui5/project/graph/Workspace~Configuration | ||
* @property {string} node.specVersion | ||
* @property {object} node.metadata Version of the project |
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 be something like "Metadata of the configuration`, right?
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.
Thanks! Correction in #568
Co-authored-by: Florian Vogt <florian.vogt@sap.com>
Implementing SAP/ui5-tooling#157
CPOUI5FOUNDATION-582